#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 */

/* Type definitions */
struct sockaddr {
  int dummy;
};
struct addrinfo {
  scalar_t__ ai_addr;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  struct addrinfo *ai_next;
};
typedef int /*<<< orphan*/ s;
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ close(int);
int connect(int, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int /*<<< orphan*/ get_in_addr(struct sockaddr *);
int getaddrinfo(char *, char *, struct addrinfo *, struct addrinfo **);
char getopt(int, char **, char *);
int /*<<< orphan*/ inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/, char *,
                             int);
int /*<<< orphan*/ isprint(char);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
char *optarg;
scalar_t__ opterr;
char optopt;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int recv(int, char *, int, int /*<<< orphan*/);
int send(int, void const *, int /*<<< orphan*/, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  int sockfd, numbytes;
  char buf[100];
  struct addrinfo hints, *servinfo, *p;
  int rv;
  char s[INET6_ADDRSTRLEN];
  char c = 0;
  char *hostname = NULL;
  char *string = NULL;
  char *port = NULL;
  if (argc == 1) {
    fprintf(stderr, "The program need the following argument:\n"
                    " - -h hostname,\n"
                    " - -p port,\n"
                    " - -s string,\n");
    return (2);
  }
  opterr = 0;
  while ((c = getopt(argc, argv, "h:p:s:")) != -1) {
    switch (c) {
    case 'h':
      hostname = optarg;
      break;
    case 'p':
      port = optarg;
      break;
    case 's':
      string = optarg;
      break;
    case '?':
      if ((optopt == 'h') || (optopt == 'p') || (optopt == 's')) {
        fprintf(stderr, "Option -%c requires an argument.\n", optopt);
      } else if (isprint(optopt)) {
        fprintf(stderr, "Unknown option `-%c'.\n", optopt);
      } else {
        fprintf(stderr, "Unknown option character `\\x%x'.\n", optopt);
      }
      return (1);
    default:
      abort();
    }
  }
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((rv = getaddrinfo(hostname, port, &hints, &servinfo)) != 0) {
    fprintf(stderr, "\e[1;31m[[SOCKET_CLIENT]\e[0m Getaddrinfo: %s\n",
            gai_strerror(rv));
    return (1);
  }
  for (p = servinfo; p != NULL; p = p->ai_next) {
    if ((sockfd = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) {
      perror("\e[1;31m[SOCKET_CLIENT]\e[0m Socket");
      continue;
    }
    if (connect(sockfd, p->ai_addr, p->ai_addrlen) == -1) {
      close(sockfd);
      perror("\e[1;31m[SOCKET_CLIENT]\e[0m Connect");
      continue;
    }
    break;
  }
  if (p == NULL) {
    fprintf(stderr, "\e[1;31m[SOCKET_CLIENT]\e[0m Failed to connect\n");
    return (2);
  }
  inet_ntop(p->ai_family, get_in_addr((struct sockaddr *)p->ai_addr), s,
            sizeof(s));
  printf("\e[1;32m[SOCKET_CLIENT]\e[0m Connecting to %s\n", s);
  freeaddrinfo(servinfo);
  if (send(sockfd, (const void *)string, strlen(string), 0) == -1) {
    perror("\e[1;31m[SOCKET_CLIENT]\e[0m Send");
    exit(1);
  }
  printf("\e[1;32m[SOCKET_CLIENT]\e[0m Sent '%s'\n", string);
  if ((numbytes = recv(sockfd, buf, 100 - 1, 0)) == -1) {
    perror("\e[1;31m[SOCKET_CLIENT]\e[0m Recv");
    exit(1);
  }
  buf[numbytes] = '\0';
  printf("\e[1;32m[SOCKET_CLIENT]\e[0m Received '%s'\n", buf);
  close(sockfd);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2d90(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x100(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0xc0(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xf8(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xc8(%rbp)
movb   $0x0,-0xc9(%rbp)
movq   $0x0,-0xd8(%rbp)
movq   $0x0,-0xe0(%rbp)
movq   $0x0,-0xe8(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    12e4 <main+0xb4>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
lea    0xd39(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0xec(%rbp)
jmp    175b <main+0x52b>
mov    0x2cc5(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xd54(%rip),%rdx
call   1100 <getopt@plt>
mov    %al,-0xc9(%rbp)
movsbl %al,%eax
cmp    $0xffffffff,%eax
je     1495 <main+0x265>
movsbl -0xc9(%rbp),%eax
mov    %eax,-0x104(%rbp)
sub    $0x3f,%eax
je     13b0 <main+0x180>
jmp    1332 <main+0x102>
mov    -0x104(%rbp),%eax
sub    $0x68,%eax
je     136e <main+0x13e>
jmp    1346 <main+0x116>
mov    -0x104(%rbp),%eax
sub    $0x70,%eax
je     1384 <main+0x154>
jmp    135a <main+0x12a>
mov    -0x104(%rbp),%eax
sub    $0x73,%eax
je     139a <main+0x16a>
jmp    1489 <main+0x259>
mov    0x2c83(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xd8(%rbp)
jmp    1490 <main+0x260>
mov    0x2c6d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xe8(%rbp)
jmp    1490 <main+0x260>
mov    0x2c57(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0xe0(%rbp)
jmp    1490 <main+0x260>
mov    0x2c19(%rip),%rax
movsbl (%rax),%eax
cmp    $0x68,%eax
je     13e9 <main+0x1b9>
mov    0x2c06(%rip),%rax
movsbl (%rax),%eax
cmp    $0x70,%eax
je     13e9 <main+0x1b9>
mov    0x2bf3(%rip),%rax
movsbl (%rax),%eax
cmp    $0x73,%eax
jne    140f <main+0x1df>
mov    0x2bd0(%rip),%rax
mov    (%rax),%edi
mov    0x2bd7(%rip),%rax
movsbl (%rax),%edx
lea    0xc58(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
jmp    1473 <main+0x243>
mov    0x2bba(%rip),%rax
movsbl (%rax),%edi
call   10e0 <isprint@plt>
cmp    $0x0,%eax
je     144d <main+0x21d>
mov    0x2b92(%rip),%rax
mov    (%rax),%edi
mov    0x2b99(%rip),%rax
movsbl (%rax),%edx
lea    0xc3c(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
jmp    146e <main+0x23e>
mov    0x2b6c(%rip),%rax
mov    (%rax),%edi
mov    0x2b73(%rip),%rax
movsbl (%rax),%edx
lea    0xc2d(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
jmp    1473 <main+0x243>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xec(%rbp)
jmp    175b <main+0x52b>
mov    $0x0,%al
call   1050 <abort@plt>
jmp    12f2 <main+0xc2>
lea    -0xa0(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
mov    0x2b29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x98(%rbp)
mov    0x2afa(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0xd8(%rbp),%rdi
mov    -0xe8(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
lea    -0xa8(%rbp),%rcx
call   1130 <getaddrinfo@plt>
mov    %eax,-0xb4(%rbp)
cmp    $0x0,%eax
je     153d <main+0x30d>
mov    0x2ac3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x108(%rbp)
mov    -0xb4(%rbp),%edi
call   10a0 <gai_strerror@plt>
mov    -0x108(%rbp),%edi
mov    %rax,%rdx
lea    0xb96(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0xec(%rbp)
jmp    175b <main+0x52b>
mov    -0xa8(%rbp),%rax
mov    %rax,-0xb0(%rbp)
cmpq   $0x0,-0xb0(%rbp)
je     15f3 <main+0x3c3>
mov    -0xb0(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0xb0(%rbp),%rax
mov    0x14(%rax),%esi
mov    -0xb0(%rbp),%rax
mov    0x10(%rax),%edx
call   1150 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
jne    1599 <main+0x369>
lea    0xb54(%rip),%rdi
call   10f0 <perror@plt>
jmp    15dc <main+0x3ac>
mov    -0x14(%rbp),%edi
mov    -0xb0(%rbp),%rax
mov    (%rax),%rsi
mov    -0xb0(%rbp),%rax
mov    0xc(%rax),%edx
call   1120 <connect@plt>
cmp    $0xffffffff,%eax
jne    15d7 <main+0x3a7>
mov    -0x14(%rbp),%edi
call   10c0 <close@plt>
lea    0xb38(%rip),%rdi
call   10f0 <perror@plt>
jmp    15dc <main+0x3ac>
jmp    15f3 <main+0x3c3>
mov    -0xb0(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0xb0(%rbp)
jmp    154b <main+0x31b>
cmpq   $0x0,-0xb0(%rbp)
jne    162e <main+0x3fe>
mov    0x29b8(%rip),%rax
mov    (%rax),%edi
lea    0xb17(%rip),%rsi
mov    $0x0,%al
call   10d0 <fprintf@plt>
movl   $0x2,-0x4(%rbp)
movl   $0x1,-0xec(%rbp)
jmp    175b <main+0x52b>
mov    -0xb0(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x118(%rbp)
mov    -0xb0(%rbp),%rax
mov    (%rax),%rdi
call   1060 <get_in_addr@plt>
mov    -0x118(%rbp),%edi
mov    -0xf8(%rbp),%rdx
mov    %eax,%esi
mov    -0x100(%rbp),%rax
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    -0xf8(%rbp),%rsi
lea    0xade(%rip),%rdi
call   1090 <printf@plt>
mov    -0xa8(%rbp),%rdi
call   1140 <freeaddrinfo@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x114(%rbp)
mov    -0xe0(%rbp),%rax
mov    %rax,-0x110(%rbp)
mov    -0xe0(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x114(%rbp),%edi
mov    -0x110(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
jne    16e1 <main+0x4b1>
lea    0xab1(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0xe0(%rbp),%rsi
lea    0xab4(%rip),%rdi
call   1090 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x80(%rbp),%rsi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
jne    1729 <main+0x4f9>
lea    0xaaf(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movslq -0x18(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
lea    -0x80(%rbp),%rsi
lea    0xaac(%rip),%rdi
call   1090 <printf@plt>
mov    -0x14(%rbp),%edi
call   10c0 <close@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xec(%rbp)
mov    -0xc0(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rsp,%r14
mov    0x2d92(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rcx
lea    0xf(%rdx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,%rsp
cmp    $0x1,%edi
jne    1287 <main+0x57>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
lea    0xd8a(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x2,%ebx
jmp    14de <main+0x2ae>
mov    %rsi,%r13
mov    %edi,%ebx
mov    %rdx,-0x50(%rbp)
mov    %rcx,-0x58(%rbp)
mov    0x2d15(%rip),%rax
movq   $0x0,(%rax)
lea    0xdab(%rip),%rdx
call   1100 <getopt@plt>
cmp    $0xff,%al
mov    %r14,-0x30(%rbp)
je     132e <main+0xfe>
xor    %ecx,%ecx
mov    %rcx,-0x40(%rbp)
mov    0x2d35(%rip),%r14
lea    0xd8a(%rip),%r12
xor    %ecx,%ecx
mov    %rcx,-0x38(%rbp)
xor    %r15d,%r15d
jmp    12f8 <main+0xc8>
cs nopw 0x0(%rax,%rax,1)
nop
mov    (%r14),%rax
mov    %rax,-0x40(%rbp)
mov    %ebx,%edi
mov    %r13,%rsi
mov    %r12,%rdx
call   1100 <getopt@plt>
cmp    $0xff,%al
je     133d <main+0x10d>
movsbl %al,%eax
cmp    $0x6f,%eax
jle    1320 <main+0xf0>
cmp    $0x70,%eax
je     12e0 <main+0xb0>
cmp    $0x73,%eax
jne    156f <main+0x33f>
mov    (%r14),%rax
mov    %rax,-0x38(%rbp)
jmp    12e7 <main+0xb7>
nopw   0x0(%rax,%rax,1)
cmp    $0x68,%eax
jne    14f2 <main+0x2c2>
mov    (%r14),%r15
jmp    12e7 <main+0xb7>
xor    %r15d,%r15d
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
mov    %rax,-0x40(%rbp)
lea    -0x78(%rbp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   10b0 <memset@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    0x2c55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
lea    -0x48(%rbp),%rcx
mov    %r15,%rdi
mov    -0x40(%rbp),%rsi
mov    %rbx,%rdx
call   1130 <getaddrinfo@plt>
test   %eax,%eax
je     13ac <main+0x17c>
mov    0x2c3a(%rip),%rcx
mov    (%rcx),%ebx
mov    %eax,%edi
call   10a0 <gai_strerror@plt>
lea    0xd20(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%ebx
jmp    14da <main+0x2aa>
mov    -0x48(%rbp),%rbx
test   %rbx,%rbx
je     1407 <main+0x1d7>
lea    0xd27(%rip),%r15
lea    0xd42(%rip),%r12
mov    0x14(%rbx),%esi
mov    0x8(%rbx),%edi
mov    0x10(%rbx),%edx
call   1150 <socket@plt>
mov    %r15,%rdi
cmp    $0xffffffff,%eax
je     13f9 <main+0x1c9>
mov    %eax,%r14d
mov    (%rbx),%rsi
mov    0xc(%rbx),%edx
mov    %eax,%edi
call   1120 <connect@plt>
cmp    $0xffffffff,%eax
jne    1428 <main+0x1f8>
mov    %r14d,%edi
call   10c0 <close@plt>
mov    %r12,%rdi
call   10f0 <perror@plt>
mov    0x18(%rbx),%rbx
test   %rbx,%rbx
jne    13c3 <main+0x193>
mov    0x2bb2(%rip),%rax
mov    (%rax),%edi
lea    0xd11(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x2,%ebx
jmp    14da <main+0x2aa>
mov    0x8(%rbx),%r15d
mov    (%rbx),%rdi
call   1060 <get_in_addr@plt>
mov    %r15d,%edi
mov    %eax,%esi
mov    -0x58(%rbp),%rbx
mov    %rbx,%rdx
mov    -0x50(%rbp),%rcx
call   1030 <inet_ntop@plt>
lea    0xd06(%rip),%rdi
mov    %rbx,%rsi
call   1090 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1140 <freeaddrinfo@plt>
mov    -0x38(%rbp),%rbx
mov    %rbx,%rdi
call   1070 <strlen@plt>
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <send@plt>
cmp    $0xffffffff,%eax
je     1576 <main+0x346>
lea    0xd17(%rip),%rdi
mov    %rbx,%rsi
call   1090 <printf@plt>
lea    -0xe0(%rbp),%rsi
xor    %ebx,%ebx
mov    %r14d,%edi
mov    $0x63,%edx
xor    %ecx,%ecx
call   1040 <recv@plt>
cmp    $0xffffffff,%eax
je     157f <main+0x34f>
cltq
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    0xd23(%rip),%rdi
lea    -0xe0(%rbp),%rsi
call   1090 <printf@plt>
mov    %r14d,%edi
call   10c0 <close@plt>
mov    -0x30(%rbp),%r14
mov    %r14,%rsp
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    $0x3f,%eax
jne    156f <main+0x33f>
mov    0x2ad2(%rip),%rbx
movzbl (%rbx),%edx
lea    -0x68(%rdx),%eax
cmp    $0xb,%al
ja     1532 <main+0x302>
movzbl %al,%eax
mov    $0x901,%ecx
bt     %rax,%rcx
jae    1532 <main+0x302>
mov    0x2aa3(%rip),%rax
mov    (%rax),%edi
lea    0xb35(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
jmp    13a2 <main+0x172>
movsbl %dl,%edi
call   10e0 <isprint@plt>
mov    0x2a7f(%rip),%rcx
mov    (%rcx),%edi
movsbl (%rbx),%edx
test   %eax,%eax
mov    -0x30(%rbp),%r14
je     1557 <main+0x327>
lea    0xb28(%rip),%rsi
jmp    155e <main+0x32e>
lea    0xb36(%rip),%rsi
xor    %eax,%eax
call   10d0 <fprintf@plt>
mov    $0x1,%ebx
jmp    14de <main+0x2ae>
xor    %eax,%eax
call   1050 <abort@plt>
lea    0xc06(%rip),%rdi
jmp    1586 <main+0x356>
lea    0xc43(%rip),%rdi
call   10f0 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i64, i32, i32, i32, i32, %struct.addrinfo* }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [84 x i8] c"The program need the following argument:\0A - -h hostname,\0A - -p port,\0A - -s string,\0A\00"
@opterr = global i64 0
@.str.1 = [7 x i8] c"h:p:s:\00"
@optarg = global i8* null
@optopt = global i8 0
@.str.2 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.3 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.4 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.5 = [45 x i8] c"\1B[1;31m[[SOCKET_CLIENT]\1B[0m Getaddrinfo: %s\0A\00"
@.str.6 = [34 x i8] c"\1B[1;31m[SOCKET_CLIENT]\1B[0m Socket\00"
@.str.7 = [35 x i8] c"\1B[1;31m[SOCKET_CLIENT]\1B[0m Connect\00"
@.str.8 = [46 x i8] c"\1B[1;31m[SOCKET_CLIENT]\1B[0m Failed to connect\0A\00"
@.str.9 = [45 x i8] c"\1B[1;32m[SOCKET_CLIENT]\1B[0m Connecting to %s\0A\00"
@.str.10 = [32 x i8] c"\1B[1;31m[SOCKET_CLIENT]\1B[0m Send\00"
@.str.11 = [38 x i8] c"\1B[1;32m[SOCKET_CLIENT]\1B[0m Sent '%s'\0A\00"
@.str.12 = [32 x i8] c"\1B[1;31m[SOCKET_CLIENT]\1B[0m Recv\00"
@.str.13 = [42 x i8] c"\1B[1;32m[SOCKET_CLIENT]\1B[0m Received '%s'\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 [100 x i8]
%9 = alloca %struct.addrinfo
%10 = alloca %struct.addrinfo*
%11 = alloca %struct.addrinfo*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i8
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* @INET6_ADDRSTRLEN
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %13
%23 = alloca i8, i64 %21
store i64 %21, i64* %14
store i8 0, i8* %15
store i8* null, i8** %16
store i8* null, i8** %17
store i8* null, i8** %18
%24 = load i32, i32* %4
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %29
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str, i64 0, i64 0))
store i32 2, i32* %3
store i32 1, i32* %19
br label %181
29: ; preds = %2
store i64 0, i64* @opterr
br label %30
30: ; preds = %80, %29
%31 = load i32, i32* %4
%32 = load i8**, i8*** %5
%33 = call signext i8 @getopt(i32 %31, i8** %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
store i8 %33, i8* %15
%34 = sext i8 %33 to i32
%35 = icmp ne i32 %34, -1
br i1 %35, label %36, label %81
36: ; preds = %30
%37 = load i8, i8* %15
%38 = sext i8 %37 to i32
switch i32 %38, label %78 [
i32 104, label %39
i32 112, label %41
i32 115, label %43
i32 63, label %45
]
39: ; preds = %36
%40 = load i8*, i8** @optarg
store i8* %40, i8** %16
br label %80
41: ; preds = %36
%42 = load i8*, i8** @optarg
store i8* %42, i8** %18
br label %80
43: ; preds = %36
%44 = load i8*, i8** @optarg
store i8* %44, i8** %17
br label %80
45: ; preds = %36
%46 = load i8, i8* @optopt
%47 = sext i8 %46 to i32
%48 = icmp eq i32 %47, 104
br i1 %48, label %57, label %49
49: ; preds = %45
%50 = load i8, i8* @optopt
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 112
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = load i8, i8* @optopt
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 115
br i1 %56, label %57, label %62
57: ; preds = %53, %49, %45
%58 = load i32, i32* @stderr
%59 = load i8, i8* @optopt
%60 = sext i8 %59 to i32
%61 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %60)
br label %77
62: ; preds = %53
%63 = load i8, i8* @optopt
%64 = call i32 @isprint(i8 signext %63)
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %71
66: ; preds = %62
%67 = load i32, i32* @stderr
%68 = load i8, i8* @optopt
%69 = sext i8 %68 to i32
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %67, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %69)
br label %76
71: ; preds = %62
%72 = load i32, i32* @stderr
%73 = load i8, i8* @optopt
%74 = sext i8 %73 to i32
%75 = call i32 (i32, i8*, ...) @fprintf(i32 %72, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %74)
br label %76
76: ; preds = %71, %66
br label %77
77: ; preds = %76, %57
store i32 1, i32* %3
store i32 1, i32* %19
br label %181
78: ; preds = %36
%79 = call i32 (...) @abort()
unreachable
80: ; preds = %43, %41, %39
br label %30
81: ; preds = %30
%82 = call i32 @memset(%struct.addrinfo* %9, i32 0, i32 32)
%83 = load i32, i32* @AF_UNSPEC
%84 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 1
store i32 %83, i32* %84
%85 = load i32, i32* @SOCK_STREAM
%86 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %9, i32 0, i32 4
store i32 %85, i32* %86
%87 = load i8*, i8** %16
%88 = load i8*, i8** %18
%89 = call i32 @getaddrinfo(i8* %87, i8* %88, %struct.addrinfo* %9, %struct.addrinfo** %10)
store i32 %89, i32* %12
%90 = icmp ne i32 %89, 0
br i1 %90, label %91, label %96
91: ; preds = %81
%92 = load i32, i32* @stderr
%93 = load i32, i32* %12
%94 = call i8* @gai_strerror(i32 %93)
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* %94)
store i32 1, i32* %3
store i32 1, i32* %19
br label %181
96: ; preds = %81
%97 = load %struct.addrinfo*, %struct.addrinfo** %10
store %struct.addrinfo* %97, %struct.addrinfo** %11
br label %98
98: ; preds = %130, %96
%99 = load %struct.addrinfo*, %struct.addrinfo** %11
%100 = icmp ne %struct.addrinfo* %99, null
br i1 %100, label %101, label %134
101: ; preds = %98
%102 = load %struct.addrinfo*, %struct.addrinfo** %11
%103 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %102, i32 0, i32 1
%104 = load i32, i32* %103
%105 = load %struct.addrinfo*, %struct.addrinfo** %11
%106 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %105, i32 0, i32 4
%107 = load i32, i32* %106
%108 = load %struct.addrinfo*, %struct.addrinfo** %11
%109 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %108, i32 0, i32 3
%110 = load i32, i32* %109
%111 = call i32 @socket(i32 %104, i32 %107, i32 %110)
store i32 %111, i32* %6
%112 = icmp eq i32 %111, -1
br i1 %112, label %113, label %115
113: ; preds = %101
%114 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0))
br label %130
115: ; preds = %101
%116 = load i32, i32* %6
%117 = load %struct.addrinfo*, %struct.addrinfo** %11
%118 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %117, i32 0, i32 0
%119 = load i64, i64* %118
%120 = load %struct.addrinfo*, %struct.addrinfo** %11
%121 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %120, i32 0, i32 2
%122 = load i32, i32* %121
%123 = call i32 @connect(i32 %116, i64 %119, i32 %122)
%124 = icmp eq i32 %123, -1
br i1 %124, label %125, label %129
125: ; preds = %115
%126 = load i32, i32* %6
%127 = call i32 @close(i32 %126)
%128 = call i32 @perror(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0))
br label %130
129: ; preds = %115
br label %134
130: ; preds = %125, %113
%131 = load %struct.addrinfo*, %struct.addrinfo** %11
%132 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %131, i32 0, i32 5
%133 = load %struct.addrinfo*, %struct.addrinfo** %132
store %struct.addrinfo* %133, %struct.addrinfo** %11
br label %98
134: ; preds = %129, %98
%135 = load %struct.addrinfo*, %struct.addrinfo** %11
%136 = icmp eq %struct.addrinfo* %135, null
br i1 %136, label %137, label %140
137: ; preds = %134
%138 = load i32, i32* @stderr
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
store i32 2, i32* %3
store i32 1, i32* %19
br label %181
140: ; preds = %134
%141 = load %struct.addrinfo*, %struct.addrinfo** %11
%142 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %141, i32 0, i32 1
%143 = load i32, i32* %142
%144 = load %struct.addrinfo*, %struct.addrinfo** %11
%145 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %144, i32 0, i32 0
%146 = load i64, i64* %145
%147 = inttoptr i64 %146 to %struct.sockaddr*
%148 = call i32 @get_in_addr(%struct.sockaddr* %147)
%149 = trunc i64 %21 to i32
%150 = call i32 @inet_ntop(i32 %143, i32 %148, i8* %23, i32 %149)
%151 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %23)
%152 = load %struct.addrinfo*, %struct.addrinfo** %10
%153 = call i32 @freeaddrinfo(%struct.addrinfo* %152)
%154 = load i32, i32* %6
%155 = load i8*, i8** %17
%156 = load i8*, i8** %17
%157 = call i32 @strlen(i8* %156)
%158 = call i32 @send(i32 %154, i8* %155, i32 %157, i32 0)
%159 = icmp eq i32 %158, -1
br i1 %159, label %160, label %163
160: ; preds = %140
%161 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%162 = call i32 @exit(i32 1)
unreachable
163: ; preds = %140
%164 = load i8*, i8** %17
%165 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i8* %164)
%166 = load i32, i32* %6
%167 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%168 = call i32 @recv(i32 %166, i8* %167, i32 99, i32 0)
store i32 %168, i32* %7
%169 = icmp eq i32 %168, -1
br i1 %169, label %170, label %173
170: ; preds = %163
%171 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0))
%172 = call i32 @exit(i32 1)
unreachable
173: ; preds = %163
%174 = load i32, i32* %7
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 %175
store i8 0, i8* %176
%177 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%178 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.13, i64 0, i64 0), i8* %177)
%179 = load i32, i32* %6
%180 = call i32 @close(i32 %179)
store i32 0, i32* %3
store i32 1, i32* %19
br label %181
181: ; preds = %173, %137, %91, %77, %26
%182 = load i8*, i8** %13
%183 = load i32, i32* %3
ret i32 %183
}

LLVM IR (-O2):
%struct.addrinfo = type { i64, i32, i32, i32, i32, %struct.addrinfo* }
%struct.sockaddr = type { i32 }
@INET6_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [84 x i8] c"The program need the following argument:\0A - -h hostname,\0A - -p port,\0A - -s string,\0A\00"
@opterr = global i64 0
@.str.1 = [7 x i8] c"h:p:s:\00"
@optarg = global i8* null
@optopt = global i8 0
@.str.2 = [34 x i8] c"Option -%c requires an argument.\0A\00"
@.str.3 = [23 x i8] c"Unknown option `-%c'.\0A\00"
@.str.4 = [34 x i8] c"Unknown option character `\\x%x'.\0A\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
@.str.5 = [45 x i8] c"\1B[1;31m[[SOCKET_CLIENT]\1B[0m Getaddrinfo: %s\0A\00"
@.str.6 = [34 x i8] c"\1B[1;31m[SOCKET_CLIENT]\1B[0m Socket\00"
@.str.7 = [35 x i8] c"\1B[1;31m[SOCKET_CLIENT]\1B[0m Connect\00"
@.str.8 = [46 x i8] c"\1B[1;31m[SOCKET_CLIENT]\1B[0m Failed to connect\0A\00"
@.str.9 = [45 x i8] c"\1B[1;32m[SOCKET_CLIENT]\1B[0m Connecting to %s\0A\00"
@.str.10 = [32 x i8] c"\1B[1;31m[SOCKET_CLIENT]\1B[0m Send\00"
@.str.11 = [38 x i8] c"\1B[1;32m[SOCKET_CLIENT]\1B[0m Sent '%s'\0A\00"
@.str.12 = [32 x i8] c"\1B[1;31m[SOCKET_CLIENT]\1B[0m Recv\00"
@.str.13 = [42 x i8] c"\1B[1;32m[SOCKET_CLIENT]\1B[0m Received '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [100 x i8]
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.addrinfo* %4 to i8*
%8 = bitcast %struct.addrinfo** %5 to i8*
%9 = load i32, i32* @INET6_ADDRSTRLEN
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = icmp eq i32 %0, 1
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([84 x i8], [84 x i8]* @.str, i64 0, i64 0))
br label %131
17: ; preds = %2
store i64 0, i64* @opterr
%18 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i8 %18, -1
br i1 %19, label %56, label %20
20: ; preds = %17, %50
%21 = phi i8 [ %54, %50 ], [ %18, %17 ]
%22 = phi i8* [ %53, %50 ], [ null, %17 ]
%23 = phi i8* [ %52, %50 ], [ null, %17 ]
%24 = phi i8* [ %51, %50 ], [ null, %17 ]
%25 = sext i8 %21 to i32
switch i32 %25, label %48 [
i32 104, label %26
i32 112, label %28
i32 115, label %30
i32 63, label %32
]
26: ; preds = %20
%27 = load i8*, i8** @optarg
br label %50
28: ; preds = %20
%29 = load i8*, i8** @optarg
br label %50
30: ; preds = %20
%31 = load i8*, i8** @optarg
br label %50
32: ; preds = %20
%33 = load i8, i8* @optopt
switch i8 %33, label %38 [
i8 115, label %34
i8 112, label %34
i8 104, label %34
]
34: ; preds = %32, %32, %32
%35 = zext i8 %33 to i32
%36 = load i32, i32* @stderr
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %131
38: ; preds = %32
%39 = tail call i32 @isprint(i8 signext %33)
%40 = icmp eq i32 %39, 0
%41 = load i32, i32* @stderr
%42 = load i8, i8* @optopt
%43 = sext i8 %42 to i32
br i1 %40, label %46, label %44
44: ; preds = %38
%45 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %43)
br label %131
46: ; preds = %38
%47 = tail call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i32 %43)
br label %131
48: ; preds = %20
%49 = tail call i32 (...) @abort()
unreachable
50: ; preds = %30, %28, %26
%51 = phi i8* [ %24, %30 ], [ %24, %28 ], [ %27, %26 ]
%52 = phi i8* [ %31, %30 ], [ %23, %28 ], [ %23, %26 ]
%53 = phi i8* [ %22, %30 ], [ %29, %28 ], [ %22, %26 ]
%54 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%55 = icmp eq i8 %54, -1
br i1 %55, label %56, label %20
56: ; preds = %50, %17
%57 = phi i8* [ null, %17 ], [ %51, %50 ]
%58 = phi i8* [ null, %17 ], [ %52, %50 ]
%59 = phi i8* [ null, %17 ], [ %53, %50 ]
%60 = call i32 @memset(%struct.addrinfo* %4, i32 0, i32 32)
%61 = load i32, i32* @AF_UNSPEC
%62 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 1
store i32 %61, i32* %62
%63 = load i32, i32* @SOCK_STREAM
%64 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %63, i32* %64
%65 = call i32 @getaddrinfo(i8* %57, i8* %59, %struct.addrinfo* %4, %struct.addrinfo** %5)
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %56
%68 = load %struct.addrinfo*, %struct.addrinfo** %5
%69 = icmp eq %struct.addrinfo* %68, null
br i1 %69, label %99, label %74
70: ; preds = %56
%71 = load i32, i32* @stderr
%72 = call i8* @gai_strerror(i32 %65)
%73 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i8* %72)
br label %131
74: ; preds = %67, %93
%75 = phi %struct.addrinfo* [ %97, %93 ], [ %68, %67 ]
%76 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i64 0, i32 1
%77 = load i32, i32* %76
%78 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i64 0, i32 4
%79 = load i32, i32* %78
%80 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i64 0, i32 3
%81 = load i32, i32* %80
%82 = call i32 @socket(i32 %77, i32 %79, i32 %81)
%83 = icmp eq i32 %82, -1
br i1 %83, label %93, label %84
84: ; preds = %74
%85 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i64 0, i32 0
%86 = load i64, i64* %85
%87 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i64 0, i32 2
%88 = load i32, i32* %87
%89 = call i32 @connect(i32 %82, i64 %86, i32 %88)
%90 = icmp eq i32 %89, -1
br i1 %90, label %91, label %102
91: ; preds = %84
%92 = call i32 @close(i32 %82)
br label %93
93: ; preds = %74, %91
%94 = phi i8* [ getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), %91 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @.str.6, i64 0, i64 0), %74 ]
%95 = call i32 @perror(i8* %94)
%96 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i64 0, i32 5
%97 = load %struct.addrinfo*, %struct.addrinfo** %96
%98 = icmp eq %struct.addrinfo* %97, null
br i1 %98, label %99, label %74
99: ; preds = %93, %67
%100 = load i32, i32* @stderr
%101 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0))
br label %131
102: ; preds = %84
%103 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i64 0, i32 1
%104 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %75, i64 0, i32 0
%105 = load i32, i32* %103
%106 = load i64, i64* %104
%107 = inttoptr i64 %106 to %struct.sockaddr*
%108 = call i32 @get_in_addr(%struct.sockaddr* %107)
%109 = call i32 @inet_ntop(i32 %105, i32 %108, i8* %12, i32 %9)
%110 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.9, i64 0, i64 0), i8* %12)
%111 = load %struct.addrinfo*, %struct.addrinfo** %5
%112 = call i32 @freeaddrinfo(%struct.addrinfo* %111)
%113 = call i32 @strlen(i8* %58)
%114 = call i32 @send(i32 %82, i8* %58, i32 %113, i32 0)
%115 = icmp eq i32 %114, -1
br i1 %115, label %116, label %119
116: ; preds = %102
%117 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%118 = call i32 @exit(i32 1)
unreachable
119: ; preds = %102
%120 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.11, i64 0, i64 0), i8* %58)
%121 = call i32 @recv(i32 %82, i8* %6, i32 99, i32 0)
%122 = icmp eq i32 %121, -1
br i1 %122, label %123, label %126
123: ; preds = %119
%124 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.12, i64 0, i64 0))
%125 = call i32 @exit(i32 1)
unreachable
126: ; preds = %119
%127 = sext i32 %121 to i64
%128 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %127
store i8 0, i8* %128
%129 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.13, i64 0, i64 0), i8* %6)
%130 = call i32 @close(i32 %82)
br label %131
131: ; preds = %34, %46, %44, %126, %99, %70, %14
%132 = phi i32 [ 2, %14 ], [ 1, %70 ], [ 2, %99 ], [ 0, %126 ], [ 1, %44 ], [ 1, %46 ], [ 1, %34 ]
ret i32 %132
}