#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;
};
typedef int /*<<< orphan*/ address;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int fcntl(int, int /*<<< orphan*/, int);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ usleep(int);
int write(int, char *, int);
int main(int argc, char *argv[]) {
  int sockfd;
  int len;
  struct sockaddr_in address;
  int res, i;
  if (argc != 2) {
    printf("Uso: robot_sync IP_ADDRESS\n");
    exit(1);
  }
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  address.sin_family = AF_INET;
  address.sin_addr.s_addr = inet_addr(argv[1]);
  address.sin_port = htons(2000);
  len = sizeof(address);
  res = connect(sockfd, (struct sockaddr *)&address, len);
  if (res == -1) {
    perror("oops: client3");
    exit(1);
  }
  printf("Cliente conectado : %i. Esperamos un momento ...\n", sockfd);
  usleep(51400);
  char getname[9] = {0x4e, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0};
  char echo[9];
  char respuesta[8];
  int ok = 0;
  int flags;
  flags = fcntl(sockfd, F_GETFL, 0);
  flags |= O_NONBLOCK;
  fcntl(sockfd, F_SETFL, flags);
  for (i = 0; i < 2; i++)
    printf("Enviando y recibiendo : ");
  while (1) {
    usleep(51400);
    printf(".");
    res = write(sockfd, &getname[0], 1);
    if (res == -1) {
      printf("Problema al escribir. Finalizando la ejecucion ...\n");
      ok = 1;
      break;
    }
    usleep(51400);
    printf(".");
    res = read(sockfd, &echo[0], 1);
    if (res == -1)
      printf(".");
    else {
      printf(".");
      res = read(sockfd, &echo[1], 8);
      if (res == 8) {
        printf(".");
        printf("\nRespuesta : %s .", &echo[0]);
        printf(".");
        res = read(sockfd, &respuesta[0], 8);
        printf("\nRespuesta : %s\n", &respuesta[0]);
        ok = 0;
      } else {
        printf("\nNo recibimos los 8 que faltaban. Recibimos: %i. Saliendo..\n",
               res);
        ok = 1;
      }
      break;
    }
  }
  close(sockfd);
  exit(ok);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11f8 <main+0x38>
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    0x2de9(%rip),%rax
mov    (%rax),%edi
mov    0x2dc0(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x14(%rbp)
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <inet_addr@plt>
mov    %eax,-0x24(%rbp)
mov    $0x7d0,%edi
call   1050 <htons@plt>
mov    %eax,-0x28(%rbp)
movl   $0xc,-0x18(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    -0x18(%rbp),%edx
call   10c0 <connect@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1276 <main+0xb6>
lea    0xdb5(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x14(%rbp),%esi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0xc8c8,%edi
call   10d0 <usleep@plt>
mov    0xe71(%rip),%rax
mov    %rax,-0x39(%rbp)
mov    0xe6f(%rip),%al
mov    %al,-0x31(%rbp)
movl   $0x0,-0x50(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1030 <fcntl@plt>
mov    %eax,-0x54(%rbp)
mov    0x2d17(%rip),%rax
mov    (%rax),%eax
or     -0x54(%rbp),%eax
mov    %eax,-0x54(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2cf5(%rip),%rax
mov    (%rax),%esi
mov    -0x54(%rbp),%edx
call   1030 <fcntl@plt>
movl   $0x0,-0x30(%rbp)
cmpl   $0x2,-0x30(%rbp)
jge    1312 <main+0x152>
lea    0xd5f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    12ec <main+0x12c>
jmp    1317 <main+0x157>
mov    $0xc8c8,%edi
call   10d0 <usleep@plt>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x39(%rbp),%rsi
mov    $0x1,%edx
call   1040 <write@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    1367 <main+0x1a7>
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x50(%rbp)
jmp    1462 <main+0x2a2>
mov    $0xc8c8,%edi
call   10d0 <usleep@plt>
lea    0xd41(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x42(%rbp),%rsi
mov    $0x1,%edx
call   1080 <read@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0xffffffff,-0x2c(%rbp)
jne    13b0 <main+0x1f0>
lea    0xd15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    145d <main+0x29d>
lea    0xd02(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x42(%rbp),%rsi
add    $0x1,%rsi
mov    $0x8,%edx
call   1080 <read@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x8,-0x2c(%rbp)
jne    1440 <main+0x280>
lea    0xcd2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x42(%rbp),%rsi
lea    0xcb0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
lea    -0x4a(%rbp),%rsi
mov    $0x8,%edx
call   1080 <read@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x4a(%rbp),%rsi
lea    0xc8e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x50(%rbp)
jmp    1458 <main+0x298>
mov    -0x2c(%rbp),%esi
lea    0xc82(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x50(%rbp)
jmp    1462 <main+0x2a2>
jmp    1317 <main+0x157>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
mov    -0x50(%rbp),%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x30,%rsp
cmp    $0x2,%edi
jne    125e <main+0x7e>
mov    %rsi,%rbp
mov    0x2ded(%rip),%r14
mov    (%r14),%edi
mov    0x2dc3(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1100 <socket@plt>
mov    %eax,%ebx
mov    (%r14),%eax
mov    %eax,0x18(%rsp)
mov    0x8(%rbp),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,0x14(%rsp)
mov    $0x7d0,%edi
call   1070 <htons@plt>
mov    %eax,0x10(%rsp)
lea    0x10(%rsp),%rsi
mov    %ebx,%edi
mov    $0xc,%edx
call   10e0 <connect@plt>
cmp    $0xffffffff,%eax
jne    1274 <main+0x94>
lea    0xdb1(%rip),%rdi
call   10c0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xe87(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
lea    0xd93(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xc8c8,%edi
call   10f0 <usleep@plt>
mov    0xe7b(%rip),%al
mov    %al,0x8(%rsp)
mov    0xe68(%rip),%rax
mov    %rax,(%rsp)
mov    0x2d16(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
xor    %edx,%edx
call   1050 <fcntl@plt>
mov    0x2d24(%rip),%rcx
or     (%rcx),%eax
mov    0x2d0b(%rip),%rcx
mov    (%rcx),%esi
mov    %ebx,%edi
mov    %eax,%edx
call   1050 <fcntl@plt>
lea    0xd69(%rip),%rbp
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0xc8c8,%edi
call   10f0 <usleep@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    %rsp,%rsi
mov    $0x1,%r14d
mov    %ebx,%edi
mov    $0x1,%edx
call   1060 <write@plt>
cmp    $0xffffffff,%eax
je     138c <main+0x1ac>
lea    0x1f(%rsp),%r15
mov    %rsp,%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0xc8c8,%edi
call   10f0 <usleep@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x1,%edx
call   10a0 <read@plt>
mov    %eax,%ebp
mov    $0x2e,%edi
call   1030 <putchar@plt>
cmp    $0xffffffff,%ebp
jne    13a7 <main+0x1c7>
mov    $0xc8c8,%edi
call   10f0 <usleep@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x1,%edx
call   1060 <write@plt>
cmp    $0xffffffff,%eax
jne    1330 <main+0x150>
lea    0xd26(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
call   1090 <close@plt>
mov    %r14d,%edi
call   10d0 <exit@plt>
lea    0x20(%rsp),%rsi
mov    %ebx,%edi
mov    $0x8,%edx
call   10a0 <read@plt>
cmp    $0x8,%eax
jne    140e <main+0x22e>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0xc8b(%rip),%rdi
xor    %r14d,%r14d
lea    0x1f(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
lea    0x28(%rsp),%rbp
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x8,%edx
call   10a0 <read@plt>
lea    0xc69(%rip),%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1398 <main+0x1b8>
lea    0xc67(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
mov    $0x1,%r14d
jmp    1398 <main+0x1b8>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [28 x i8] c"Uso: robot_sync IP_ADDRESS\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [14 x i8] c"oops: client3\00"
@.str.2 = [50 x i8] c"Cliente conectado : %i. Esperamos un momento ...\0A\00"
@__const.main.getname = <{ i8, [8 x i8] }> <{ i8 78, [8 x i8] zeroinitializer }>
@F_GETFL = global i32 0
@O_NONBLOCK = global i32 0
@F_SETFL = global i32 0
@.str.3 = [25 x i8] c"Enviando y recibiendo : \00"
@.str.4 = [2 x i8] c".\00"
@.str.5 = [52 x i8] c"Problema al escribir. Finalizando la ejecucion ...\0A\00"
@.str.6 = [18 x i8] c"\0ARespuesta : %s .\00"
@.str.7 = [17 x i8] c"\0ARespuesta : %s\0A\00"
@.str.8 = [61 x i8] c"\0ANo recibimos los 8 que faltaban. Recibimos: %i. Saliendo..\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 %struct.sockaddr_in
%9 = alloca i32
%10 = alloca i32
%11 = alloca [9 x i8]
%12 = alloca [9 x i8]
%13 = alloca [8 x i8]
%14 = alloca i32
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp ne i32 %16, 2
br i1 %17, label %18, label %21
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = load i32, i32* @AF_INET
%23 = load i32, i32* @SOCK_STREAM
%24 = call i32 @socket(i32 %22, i32 %23, i32 0)
store i32 %24, i32* %6
%25 = load i32, i32* @AF_INET
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 2
store i32 %25, i32* %26
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32 @inet_addr(i8* %29)
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%32 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %31, i32 0, i32 0
store i32 %30, i32* %32
%33 = call i32 @htons(i32 2000)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
store i32 %33, i32* %34
store i32 12, i32* %7
%35 = load i32, i32* %6
%36 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%37 = load i32, i32* %7
%38 = call i32 @connect(i32 %35, %struct.sockaddr* %36, i32 %37)
store i32 %38, i32* %9
%39 = load i32, i32* %9
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %44
41: ; preds = %21
%42 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %21
%45 = load i32, i32* %6
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = call i32 @usleep(i32 51400)
%48 = bitcast [9 x i8]* %11 to i8*
store i32 0, i32* %14
%49 = load i32, i32* %6
%50 = load i32, i32* @F_GETFL
%51 = call i32 @fcntl(i32 %49, i32 %50, i32 0)
store i32 %51, i32* %15
%52 = load i32, i32* @O_NONBLOCK
%53 = load i32, i32* %15
%54 = or i32 %53, %52
store i32 %54, i32* %15
%55 = load i32, i32* %6
%56 = load i32, i32* @F_SETFL
%57 = load i32, i32* %15
%58 = call i32 @fcntl(i32 %55, i32 %56, i32 %57)
store i32 0, i32* %10
br label %59
59: ; preds = %64, %44
%60 = load i32, i32* %10
%61 = icmp slt i32 %60, 2
br i1 %61, label %62, label %67
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %64
64: ; preds = %62
%65 = load i32, i32* %10
%66 = add nsw i32 %65, 1
store i32 %66, i32* %10
br label %59
67: ; preds = %59
br label %68
68: ; preds = %67, %109
%69 = call i32 @usleep(i32 51400)
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%71 = load i32, i32* %6
%72 = getelementptr inbounds [9 x i8], [9 x i8]* %11, i64 0, i64 0
%73 = call i32 @write(i32 %71, i8* %72, i32 1)
store i32 %73, i32* %9
%74 = load i32, i32* %9
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %78
76: ; preds = %68
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0))
store i32 1, i32* %14
br label %110
78: ; preds = %68
%79 = call i32 @usleep(i32 51400)
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%81 = load i32, i32* %6
%82 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 0
%83 = call i32 @read(i32 %81, i8* %82, i32 1)
store i32 %83, i32* %9
%84 = load i32, i32* %9
%85 = icmp eq i32 %84, -1
br i1 %85, label %86, label %88
86: ; preds = %78
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %109
88: ; preds = %78
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%90 = load i32, i32* %6
%91 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 1
%92 = call i32 @read(i32 %90, i8* %91, i32 8)
store i32 %92, i32* %9
%93 = load i32, i32* %9
%94 = icmp eq i32 %93, 8
br i1 %94, label %95, label %105
95: ; preds = %88
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%97 = getelementptr inbounds [9 x i8], [9 x i8]* %12, i64 0, i64 0
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %97)
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%100 = load i32, i32* %6
%101 = getelementptr inbounds [8 x i8], [8 x i8]* %13, i64 0, i64 0
%102 = call i32 @read(i32 %100, i8* %101, i32 8)
store i32 %102, i32* %9
%103 = getelementptr inbounds [8 x i8], [8 x i8]* %13, i64 0, i64 0
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %103)
store i32 0, i32* %14
br label %108
105: ; preds = %88
%106 = load i32, i32* %9
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0), i32 %106)
store i32 1, i32* %14
br label %108
108: ; preds = %105, %95
br label %110
109: ; preds = %86
br label %68
110: ; preds = %108, %76
%111 = load i32, i32* %6
%112 = call i32 @close(i32 %111)
%113 = load i32, i32* %14
%114 = call i32 @exit(i32 %113)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [14 x i8] c"oops: client3\00"
@.str.2 = [50 x i8] c"Cliente conectado : %i. Esperamos un momento ...\0A\00"
@__const.main.getname = <{ i8, [8 x i8] }> <{ i8 78, [8 x i8] zeroinitializer }>
@F_GETFL = global i32 0
@O_NONBLOCK = global i32 0
@F_SETFL = global i32 0
@.str.3 = [25 x i8] c"Enviando y recibiendo : \00"
@.str.6 = [18 x i8] c"\0ARespuesta : %s .\00"
@.str.7 = [17 x i8] c"\0ARespuesta : %s\0A\00"
@.str.8 = [61 x i8] c"\0ANo recibimos los 8 que faltaban. Recibimos: %i. Saliendo..\0A\00"
@str = [51 x i8] c"Problema al escribir. Finalizando la ejecucion ...\00"
@str.9 = [27 x i8] c"Uso: robot_sync IP_ADDRESS\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca [9 x i8]
%5 = alloca [9 x i8]
%6 = alloca [8 x i8]
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = icmp eq i32 %0, 2
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = tail call i32 @socket(i32 %13, i32 %14, i32 0)
%16 = load i32, i32* @AF_INET
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %16, i32* %17
%18 = getelementptr inbounds i8*, i8** %1, i64 1
%19 = load i8*, i8** %18
%20 = tail call i32 @inet_addr(i8* %19)
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %20, i32* %21
%22 = tail call i32 @htons(i32 2000)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %22, i32* %23
%24 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%25 = call i32 @connect(i32 %15, %struct.sockaddr* %24, i32 12)
%26 = icmp eq i32 %25, -1
br i1 %26, label %27, label %30
27: ; preds = %12
%28 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %12
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%32 = call i32 @usleep(i32 51400)
%33 = getelementptr inbounds [9 x i8], [9 x i8]* %4, i64 0, i64 0
%34 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 0
%35 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%36 = load i32, i32* @F_GETFL
%37 = call i32 @fcntl(i32 %15, i32 %36, i32 0)
%38 = load i32, i32* @O_NONBLOCK
%39 = or i32 %38, %37
%40 = load i32, i32* @F_SETFL
%41 = call i32 @fcntl(i32 %15, i32 %40, i32 %39)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @usleep(i32 51400)
%45 = call i32 @putchar(i32 46)
%46 = call i32 @write(i32 %15, i8* %33, i32 1)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %56, %30
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str, i64 0, i64 0))
br label %73
50: ; preds = %30, %56
%51 = call i32 @usleep(i32 51400)
%52 = call i32 @putchar(i32 46)
%53 = call i32 @read(i32 %15, i8* %34, i32 1)
%54 = icmp eq i32 %53, -1
%55 = call i32 @putchar(i32 46)
br i1 %54, label %56, label %61
56: ; preds = %50
%57 = call i32 @usleep(i32 51400)
%58 = call i32 @putchar(i32 46)
%59 = call i32 @write(i32 %15, i8* %33, i32 1)
%60 = icmp eq i32 %59, -1
br i1 %60, label %48, label %50
61: ; preds = %50
%62 = getelementptr inbounds [9 x i8], [9 x i8]* %5, i64 0, i64 1
%63 = call i32 @read(i32 %15, i8* %62, i32 8)
%64 = icmp eq i32 %63, 8
br i1 %64, label %65, label %71
65: ; preds = %61
%66 = call i32 @putchar(i32 46)
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.6, i64 0, i64 0), i8* %34)
%68 = call i32 @putchar(i32 46)
%69 = call i32 @read(i32 %15, i8* %35, i32 8)
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %35)
br label %73
71: ; preds = %61
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @.str.8, i64 0, i64 0), i32 %63)
br label %73
73: ; preds = %65, %71, %48
%74 = phi i32 [ 1, %48 ], [ 0, %65 ], [ 1, %71 ]
%75 = call i32 @close(i32 %15)
%76 = call i32 @exit(i32 %74)
unreachable
}