#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 /*<<< orphan*/ read(int, char *, int);
int /*<<< orphan*/ sleep(int);
int socket(void *, int /*<<< orphan*/, int /*<<< orphan*/);
int strlen(char const *);
int /*<<< orphan*/ write(int, char const *, int);
int main(int argc, char const *argv[]) {
  if (argc < 3) {
    printf("%s\n", "Usage: \n\t ./train <port> <bogey sequence>\n");
    exit(1);
  };
  struct sockaddr_in s_addr;
  int sfd, _sfd, port;
  char buf[128];
  port = atoi(argv[1]);
  memset((char *)&s_addr, 0, sizeof(s_addr));
  if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
    printf("%s\n", "socket() error");
    exit(1);
  };
  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 (connect(sfd, (struct sockaddr *)&s_addr, sizeof(s_addr)) < 0) {
    printf("%s\n", "connect() error");
    exit(1);
  };
  read(sfd, buf, 128);
  port = atoi(buf);
  close(sfd);
  printf("Got response %s\n", buf);
  if (port == -1) {
    printf("Platform not available! Try again !\n");
  } else {
    memset((char *)&s_addr, 0, sizeof(s_addr));
    if ((sfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
      printf("%s\n", "socket() error");
      exit(1);
    };
    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");
    printf("connecting again !\n");
    if (connect(sfd, (struct sockaddr *)&s_addr, sizeof(s_addr)) < 0) {
      printf("%s\n", "connect() error");
      exit(1);
    };
    write(sfd, argv[2], strlen(argv[2]));
    printf("written sequence\n");
    sleep(2);
    write(sfd, "-1", 2);
  }
  sleep(2);
  close(sfd);
  printf("Leaving !\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1212 <main+0x42>
lea    0xe67(%rip),%rdi
lea    0xdff(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x34(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%rdi
mov    0x2d95(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    1277 <main+0xa7>
lea    0xe02(%rip),%rdi
lea    0xdc5(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2d6a(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x34(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0x20(%rbp)
lea    0xda2(%rip),%rdi
call   10a0 <inet_addr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x18,%edx
call   10d0 <connect@plt>
cmp    $0x0,%rax
jge    12db <main+0x10b>
lea    0xd9e(%rip),%rdi
lea    0xd7a(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x2c(%rbp),%edi
lea    -0xc0(%rbp),%rsi
mov    $0x80,%edx
call   1090 <read@plt>
lea    -0xc0(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x34(%rbp)
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
lea    -0xc0(%rbp),%rsi
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0xffffffff,-0x34(%rbp)
jne    1338 <main+0x168>
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1464 <main+0x294>
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1070 <memset@plt>
mov    0x2c99(%rip),%rax
mov    (%rax),%rdi
mov    0x2c7f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    138d <main+0x1bd>
lea    0xcec(%rip),%rdi
lea    0xcaf(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2c54(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x34(%rbp),%edi
call   1050 <htons@plt>
mov    %rax,-0x20(%rbp)
lea    0xc8c(%rip),%rdi
call   10a0 <inet_addr@plt>
mov    %rax,-0x28(%rbp)
lea    0xccc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x2c(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0x18,%edx
call   10d0 <connect@plt>
cmp    $0x0,%rax
jge    13ff <main+0x22f>
lea    0xc7a(%rip),%rdi
lea    0xc56(%rip),%rsi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0xcc(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
mov    -0xcc(%rbp),%edi
mov    -0xc8(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
lea    0xc5f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x2,%edi
call   10e0 <sleep@plt>
mov    -0x2c(%rbp),%edi
lea    0xc56(%rip),%rsi
mov    $0x2,%edx
call   1030 <write@plt>
mov    $0x2,%edi
call   10e0 <sleep@plt>
mov    -0x2c(%rbp),%edi
call   1080 <close@plt>
lea    0xc36(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa8,%rsp
cmp    $0x2,%edi
jle    13cc <main+0x1ec>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
call   10c0 <atoi@plt>
mov    %eax,%ebx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    0x2dc8(%rip),%r12
mov    (%r12),%rdi
mov    0x2dad(%rip),%r13
mov    0x0(%r13),%esi
xor    %edx,%edx
call   1100 <socket@plt>
cmp    $0xffffffff,%eax
je     13ba <main+0x1da>
mov    %eax,%ebp
mov    (%r12),%rax
mov    %rax,0x18(%rsp)
mov    %ebx,%edi
call   1060 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0xddd(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %rax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
mov    $0x18,%edx
call   10e0 <connect@plt>
test   %rax,%rax
js     13c3 <main+0x1e3>
lea    0x20(%rsp),%rbx
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x80,%edx
call   10a0 <read@plt>
mov    %rbx,%rdi
call   10c0 <atoi@plt>
mov    %eax,%r15d
mov    %ebp,%edi
call   1090 <close@plt>
lea    0xda6(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
cmp    $0xffffffff,%r15d
je     137d <main+0x19d>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1080 <memset@plt>
mov    (%r12),%rdi
mov    0x0(%r13),%esi
xor    %edx,%edx
call   1100 <socket@plt>
cmp    $0xffffffff,%eax
je     13ba <main+0x1da>
mov    %eax,%ebp
mov    (%r12),%rax
mov    %rax,0x18(%rsp)
mov    %r15d,%edi
call   1060 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0xd30(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %rax,0x8(%rsp)
lea    0xd4d(%rip),%rdi
call   1030 <puts@plt>
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
mov    $0x18,%edx
call   10e0 <connect@plt>
test   %rax,%rax
js     13c3 <main+0x1e3>
mov    0x10(%r14),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <write@plt>
lea    0xd22(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
lea    0xcf6(%rip),%rsi
mov    %ebp,%edi
mov    $0x2,%edx
call   1040 <write@plt>
jmp    1389 <main+0x1a9>
lea    0xd12(%rip),%rdi
call   1030 <puts@plt>
mov    $0x2,%edi
call   10f0 <sleep@plt>
mov    %ebp,%edi
call   1090 <close@plt>
lea    0xceb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xa8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc6a(%rip),%rdi
jmp    13d3 <main+0x1f3>
lea    0xc7a(%rip),%rdi
jmp    13d3 <main+0x1f3>
lea    0xc2d(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   10d0 <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 = [43 x i8] c"Usage: \0A\09 ./train <port> <bogey sequence>\0A\00"
@AF_INET = global i8* null
@SOCK_STREAM = global i32 0
@.str.2 = [15 x i8] c"socket() error\00"
@.str.3 = [10 x i8] c"127.0.0.1\00"
@.str.4 = [16 x i8] c"connect() error\00"
@.str.5 = [17 x i8] c"Got response %s\0A\00"
@.str.6 = [37 x i8] c"Platform not available! Try again !\0A\00"
@.str.7 = [20 x i8] c"connecting again !\0A\00"
@.str.8 = [18 x i8] c"written sequence\0A\00"
@.str.9 = [3 x i8] c"-1\00"
@.str.10 = [11 x i8] c"Leaving !\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [128 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 @atoi(i8* %19)
store i32 %20, i32* %9
%21 = bitcast %struct.sockaddr_in* %6 to i8*
%22 = call i32 @memset(i8* %21, i32 0, i32 24)
%23 = load i8*, i8** @AF_INET
%24 = load i32, i32* @SOCK_STREAM
%25 = call i32 @socket(i8* %23, i32 %24, i32 0)
store i32 %25, i32* %7
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %16
%28 = 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.2, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %16
%31 = load i8*, i8** @AF_INET
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i8* %31, i8** %32
%33 = load i32, i32* %9
%34 = call i8* @htons(i32 %33)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
store i8* %34, i8** %35
%36 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%38 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %37, i32 0, i32 0
store i8* %36, i8** %38
%39 = load i32, i32* %7
%40 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%41 = call i64 @connect(i32 %39, %struct.sockaddr* %40, i32 24)
%42 = icmp slt i64 %41, 0
br i1 %42, label %43, label %46
43: ; preds = %30
%44 = 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.4, i64 0, i64 0))
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %30
%47 = load i32, i32* %7
%48 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%49 = call i32 @read(i32 %47, i8* %48, i32 128)
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%51 = call i32 @atoi(i8* %50)
store i32 %51, i32* %9
%52 = load i32, i32* %7
%53 = call i32 @close(i32 %52)
%54 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = load i32, i32* %9
%57 = icmp eq i32 %56, -1
br i1 %57, label %58, label %60
58: ; preds = %46
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.6, i64 0, i64 0))
br label %101
60: ; preds = %46
%61 = bitcast %struct.sockaddr_in* %6 to i8*
%62 = call i32 @memset(i8* %61, i32 0, i32 24)
%63 = load i8*, i8** @AF_INET
%64 = load i32, i32* @SOCK_STREAM
%65 = call i32 @socket(i8* %63, i32 %64, i32 0)
store i32 %65, i32* %7
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %70
67: ; preds = %60
%68 = 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.2, i64 0, i64 0))
%69 = call i32 @exit(i32 1)
unreachable
70: ; preds = %60
%71 = load i8*, i8** @AF_INET
%72 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i8* %71, i8** %72
%73 = load i32, i32* %9
%74 = call i8* @htons(i32 %73)
%75 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
store i8* %74, i8** %75
%76 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%77 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%78 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %77, i32 0, i32 0
store i8* %76, i8** %78
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
%80 = load i32, i32* %7
%81 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%82 = call i64 @connect(i32 %80, %struct.sockaddr* %81, i32 24)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %87
84: ; preds = %70
%85 = 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.4, i64 0, i64 0))
%86 = call i32 @exit(i32 1)
unreachable
87: ; preds = %70
%88 = load i32, i32* %7
%89 = load i8**, i8*** %5
%90 = getelementptr inbounds i8*, i8** %89, i64 2
%91 = load i8*, i8** %90
%92 = load i8**, i8*** %5
%93 = getelementptr inbounds i8*, i8** %92, i64 2
%94 = load i8*, i8** %93
%95 = call i32 @strlen(i8* %94)
%96 = call i32 @write(i32 %88, i8* %91, i32 %95)
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%98 = call i32 @sleep(i32 2)
%99 = load i32, i32* %7
%100 = call i32 @write(i32 %99, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
br label %101
101: ; preds = %87, %58
%102 = call i32 @sleep(i32 2)
%103 = load i32, i32* %7
%104 = call i32 @close(i32 %103)
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
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 = [43 x i8] c"Usage: \0A\09 ./train <port> <bogey sequence>\0A\00"
@AF_INET = global i8* null
@SOCK_STREAM = global i32 0
@.str.2 = [15 x i8] c"socket() error\00"
@.str.3 = [10 x i8] c"127.0.0.1\00"
@.str.4 = [16 x i8] c"connect() error\00"
@.str.5 = [17 x i8] c"Got response %s\0A\00"
@.str.9 = [3 x i8] c"-1\00"
@str = [19 x i8] c"connecting again !\00"
@str.11 = [17 x i8] c"written sequence\00"
@str.12 = [10 x i8] c"Leaving !\00"
@str.13 = [36 x i8] c"Platform not available! Try again !\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [128 x i8]
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = bitcast %struct.sockaddr_in* %3 to i8*
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i32 @atoi(i8* %13)
%15 = call i32 @memset(i8* %10, i32 0, i32 24)
%16 = load i8*, i8** @AF_INET
%17 = load i32, i32* @SOCK_STREAM
%18 = call i32 @socket(i8* %16, i32 %17, i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %9
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %9
%24 = load i8*, i8** @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i8* %24, i8** %25
%26 = call i8* @htons(i32 %14)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, 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* %3, i64 0, i32 0, i32 0
store i8* %28, i8** %29
%30 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%31 = call i64 @connect(i32 %18, %struct.sockaddr* %30, i32 24)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %23
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %23
%37 = call i32 @read(i32 %18, i8* %11, i32 128)
%38 = call i32 @atoi(i8* %11)
%39 = call i32 @close(i32 %18)
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %11)
%41 = icmp eq i32 %38, -1
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.13, i64 0, i64 0))
br label %71
44: ; preds = %36
%45 = call i32 @memset(i8* %10, i32 0, i32 24)
%46 = load i8*, i8** @AF_INET
%47 = load i32, i32* @SOCK_STREAM
%48 = call i32 @socket(i8* %46, i32 %47, i32 0)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %53
50: ; preds = %44
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %44
%54 = load i8*, i8** @AF_INET
store i8* %54, i8** %25
%55 = call i8* @htons(i32 %38)
store i8* %55, i8** %27
%56 = call i8* @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
store i8* %56, i8** %29
%57 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
%58 = call i64 @connect(i32 %48, %struct.sockaddr* %30, i32 24)
%59 = icmp slt i64 %58, 0
br i1 %59, label %60, label %63
60: ; preds = %53
%61 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%62 = call i32 @exit(i32 1)
unreachable
63: ; preds = %53
%64 = getelementptr inbounds i8*, i8** %1, i64 2
%65 = load i8*, i8** %64
%66 = call i32 @strlen(i8* %65)
%67 = call i32 @write(i32 %48, i8* %65, i32 %66)
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.11, i64 0, i64 0))
%69 = call i32 @sleep(i32 2)
%70 = call i32 @write(i32 %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32 2)
br label %71
71: ; preds = %63, %42
%72 = phi i32 [ %18, %42 ], [ %48, %63 ]
%73 = call i32 @sleep(i32 2)
%74 = call i32 @close(i32 %72)
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.12, i64 0, i64 0))
ret i32 0
}