#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*/ uint8_t;
typedef int /*<<< orphan*/ uint16_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef size_t ssize_t;
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EXIT_FAILURE;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SHUT_RDWR;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
size_t fread(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ htons(int /*<<< orphan*/);
int /*<<< orphan*/ inet_addr(char const *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
size_t send(int, int /*<<< orphan*/ *, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int client_tcp(const char *serverip, uint16_t server_port, const char *file) {
  uint8_t *buffer;
  int sock;
  socklen_t client_addr_len;
  FILE *fp;
  size_t read_items = 0;
  ssize_t data_sent;
  struct sockaddr *client_addr;
  buffer = (uint8_t *)malloc(4096);
  if (!buffer) {
    perror("Allocate application receive buffer");
    return -EXIT_FAILURE;
  }
  fp = fopen(file, "r");
  if (!fp) {
    perror("Open file for reading");
    free(buffer);
    return -EXIT_FAILURE;
  }
  if ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
    perror("Opening TCP socket");
    free(buffer);
    fclose(fp);
    return -EXIT_FAILURE;
  }
  struct sockaddr_in sin;
  memset(&sin, 0, sizeof(struct sockaddr_in));
  sin.sin_family = AF_INET;
  sin.sin_port = htons(server_port);
  sin.sin_addr.s_addr = inet_addr(serverip);
  if (connect(sock, (struct sockaddr *)&sin, sizeof(struct sockaddr_in)) ==
      -1) {
    perror("TCP connect");
    exit(EXIT_FAILURE);
  }
  printf("Starting sending data...\n");
  while (!feof(fp)) {
    read_items = fread(buffer, sizeof(uint8_t), 4096, fp);
    if (read_items < 1) {
      perror("Failed read from file");
      shutdown(sock, SHUT_RDWR);
      close(sock);
      free(buffer);
      fclose(fp);
      return -EXIT_FAILURE;
    }
    data_sent = send(sock, buffer, read_items * sizeof(uint8_t), 0);
    if (data_sent != read_items * sizeof(uint8_t)) {
      printf("Failed to send the"
             " amount of data read from the file.\n");
      shutdown(sock, SHUT_RDWR);
      close(sock);
      free(buffer);
      fclose(fp);
      return -EXIT_FAILURE;
    }
  }
  printf("Data sent. Terminating...\n");
  shutdown(sock, SHUT_RDWR);
  close(sock);
  free(buffer);
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<client_tcp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movq   $0x0,-0x40(%rbp)
mov    $0x1000,%edi
call   10e0 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1263 <client_tcp+0x53>
lea    0xdb5(%rip),%rdi
call   1100 <perror@plt>
xor    %eax,%eax
mov    0x2d67(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    14c4 <client_tcp+0x2b4>
mov    -0x20(%rbp),%rdi
lea    0xdb4(%rip),%rsi
call   10f0 <fopen@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    12aa <client_tcp+0x9a>
lea    0xd9b(%rip),%rdi
call   1100 <perror@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
mov    0x2d20(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    14c4 <client_tcp+0x2b4>
mov    0x2d2f(%rip),%rax
mov    (%rax),%edi
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
mov    0x2d15(%rip),%rax
mov    (%rax),%edx
call   1130 <socket@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0xffffffff,%eax
jne    1307 <client_tcp+0xf7>
lea    0xd5d(%rip),%rdi
call   1100 <perror@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
mov    0x2cc3(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    14c4 <client_tcp+0x2b4>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10a0 <memset@plt>
mov    0x2cc2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x58(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <htons@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,-0x60(%rbp)
mov    -0x2c(%rbp),%edi
lea    -0x60(%rbp),%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0xffffffff,%eax
jne    136e <client_tcp+0x15e>
lea    0xcf2(%rip),%rdi
call   1100 <perror@plt>
mov    0x2c59(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    0xce4(%rip),%rdi
call   1090 <printf@plt>
mov    -0x38(%rbp),%rdi
call   10d0 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1398 <client_tcp+0x188>
jmp    1486 <client_tcp+0x276>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x4,%esi
mov    $0x1000,%edx
call   1040 <fread@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x1,-0x40(%rbp)
jae    1408 <client_tcp+0x1f8>
lea    0xcae(%rip),%rdi
call   1100 <perror@plt>
mov    -0x2c(%rbp),%edi
mov    0x2c1c(%rip),%rax
mov    (%rax),%esi
call   1060 <shutdown@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
mov    0x2bc2(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    14c4 <client_tcp+0x2b4>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x40(%rbp),%rdx
shl    $0x2,%rdx
xor    %ecx,%ecx
call   1080 <send@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    -0x40(%rbp),%rcx
shl    $0x2,%rcx
cmp    %rcx,%rax
je     1481 <client_tcp+0x271>
lea    0xc4b(%rip),%rdi
call   1090 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    0x2ba3(%rip),%rax
mov    (%rax),%esi
call   1060 <shutdown@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
mov    0x2b49(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,-0x4(%rbp)
jmp    14c4 <client_tcp+0x2b4>
jmp    137a <client_tcp+0x16a>
lea    0xc33(%rip),%rdi
call   1090 <printf@plt>
mov    -0x2c(%rbp),%edi
mov    0x2b54(%rip),%rax
mov    (%rax),%esi
call   1060 <shutdown@plt>
mov    -0x2c(%rbp),%edi
call   10b0 <close@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x38(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client_tcp>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%rbx
mov    %esi,%r12d
mov    %rdi,%rbp
mov    $0x1000,%edi
call   10e0 <malloc@plt>
test   %rax,%rax
je     13be <client_tcp+0x1ae>
mov    %rax,%r14
lea    0xdde(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <fopen@plt>
test   %rax,%rax
je     13cc <client_tcp+0x1bc>
mov    %rax,%rbx
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
mov    0x2d60(%rip),%rax
mov    (%rax),%esi
mov    0x2d67(%rip),%rax
mov    (%rax),%edx
call   1130 <socket@plt>
cmp    $0xffffffff,%eax
je     13e2 <client_tcp+0x1d2>
mov    %eax,%r13d
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   10a0 <memset@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    %r12d,%edi
call   1080 <htons@plt>
mov    %eax,0xc(%rsp)
mov    %rbp,%rdi
call   10c0 <inet_addr@plt>
mov    %eax,0x8(%rsp)
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1120 <connect@plt>
cmp    $0xffffffff,%eax
je     1404 <client_tcp+0x1f4>
lea    0xd92(%rip),%rdi
call   1040 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
call   10d0 <feof@plt>
test   %eax,%eax
jne    1378 <client_tcp+0x168>
mov    %r14,%rdi
mov    $0x4,%esi
mov    $0x1000,%edx
mov    %rbx,%rcx
call   1050 <fread@plt>
test   %rax,%rax
je     13f3 <client_tcp+0x1e3>
mov    %rax,%rbp
shl    $0x2,%rbp
mov    %r13d,%edi
mov    %r14,%rsi
mov    %rbp,%rdx
xor    %ecx,%ecx
call   1090 <send@plt>
cmp    %rbp,%rax
je     12f0 <client_tcp+0xe0>
lea    0xd65(%rip),%rdi
call   1040 <puts@plt>
mov    0x2ca7(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
call   1070 <shutdown@plt>
mov    %r13d,%edi
call   10b0 <close@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    0x2c4e(%rip),%rcx
xor    %eax,%eax
sub    (%rcx),%eax
jmp    13af <client_tcp+0x19f>
lea    0xd09(%rip),%rdi
call   1040 <puts@plt>
mov    0x2c65(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
call   1070 <shutdown@plt>
mov    %r13d,%edi
call   10b0 <close@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc3b(%rip),%rdi
call   1100 <perror@plt>
jmp    136b <client_tcp+0x15b>
lea    0xc51(%rip),%rdi
call   1100 <perror@plt>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    136b <client_tcp+0x15b>
lea    0xc51(%rip),%rdi
call   1100 <perror@plt>
jmp    135b <client_tcp+0x14b>
lea    0xc5f(%rip),%rdi
call   1100 <perror@plt>
jmp    1342 <client_tcp+0x132>
lea    0xc42(%rip),%rdi
call   1100 <perror@plt>
mov    0x2ba9(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
@.str = [36 x i8] c"Allocate application receive buffer\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"Open file for reading\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [19 x i8] c"Opening TCP socket\00"
@.str.4 = [12 x i8] c"TCP connect\00"
@.str.5 = [26 x i8] c"Starting sending data...\0A\00"
@.str.6 = [22 x i8] c"Failed read from file\00"
@SHUT_RDWR = global i32 0
@.str.7 = [55 x i8] c"Failed to send the amount of data read from the file.\0A\00"
@.str.8 = [27 x i8] c"Data sent. Terminating...\0A\00"
define i32 @client_tcp(i8* %0, i32 %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i64
%13 = alloca i64
%14 = alloca %struct.sockaddr*
%15 = alloca %struct.sockaddr_in
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i64 0, i64* %12
%16 = call i64 @malloc(i32 4096)
%17 = inttoptr i64 %16 to i32*
store i32* %17, i32** %8
%18 = load i32*, i32** %8
%19 = icmp ne i32* %18, null
br i1 %19, label %24, label %20
20: ; preds = %3
%21 = call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = sub nsw i32 0, %22
store i32 %23, i32* %4
br label %129
24: ; preds = %3
%25 = load i8*, i8** %7
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %26, i32** %11
%27 = load i32*, i32** %11
%28 = icmp ne i32* %27, null
br i1 %28, label %35, label %29
29: ; preds = %24
%30 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%31 = load i32*, i32** %8
%32 = call i32 @free(i32* %31)
%33 = load i32, i32* @EXIT_FAILURE
%34 = sub nsw i32 0, %33
store i32 %34, i32* %4
br label %129
35: ; preds = %24
%36 = load i32, i32* @AF_INET
%37 = load i32, i32* @SOCK_STREAM
%38 = load i32, i32* @IPPROTO_TCP
%39 = call i32 @socket(i32 %36, i32 %37, i32 %38)
store i32 %39, i32* %9
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %49
41: ; preds = %35
%42 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32*, i32** %8
%44 = call i32 @free(i32* %43)
%45 = load i32*, i32** %11
%46 = call i32 @fclose(i32* %45)
%47 = load i32, i32* @EXIT_FAILURE
%48 = sub nsw i32 0, %47
store i32 %48, i32* %4
br label %129
49: ; preds = %35
%50 = call i32 @memset(%struct.sockaddr_in* %15, i32 0, i32 12)
%51 = load i32, i32* @AF_INET
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 2
store i32 %51, i32* %52
%53 = load i32, i32* %6
%54 = call i32 @htons(i32 %53)
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
store i32 %54, i32* %55
%56 = load i8*, i8** %5
%57 = call i32 @inet_addr(i8* %56)
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 0
%59 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %58, i32 0, i32 0
store i32 %57, i32* %59
%60 = load i32, i32* %9
%61 = bitcast %struct.sockaddr_in* %15 to %struct.sockaddr*
%62 = call i32 @connect(i32 %60, %struct.sockaddr* %61, i32 12)
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %68
64: ; preds = %49
%65 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%66 = load i32, i32* @EXIT_FAILURE
%67 = call i32 @exit(i32 %66)
unreachable
68: ; preds = %49
%69 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
br label %70
70: ; preds = %117, %68
%71 = load i32*, i32** %11
%72 = call i32 @feof(i32* %71)
%73 = icmp ne i32 %72, 0
%74 = xor i1 %73, true
br i1 %74, label %75, label %118
75: ; preds = %70
%76 = load i32*, i32** %8
%77 = load i32*, i32** %11
%78 = call i64 @fread(i32* %76, i32 4, i32 4096, i32* %77)
store i64 %78, i64* %12
%79 = load i64, i64* %12
%80 = icmp ult i64 %79, 1
br i1 %80, label %81, label %94
81: ; preds = %75
%82 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%83 = load i32, i32* %9
%84 = load i32, i32* @SHUT_RDWR
%85 = call i32 @shutdown(i32 %83, i32 %84)
%86 = load i32, i32* %9
%87 = call i32 @close(i32 %86)
%88 = load i32*, i32** %8
%89 = call i32 @free(i32* %88)
%90 = load i32*, i32** %11
%91 = call i32 @fclose(i32* %90)
%92 = load i32, i32* @EXIT_FAILURE
%93 = sub nsw i32 0, %92
store i32 %93, i32* %4
br label %129
94: ; preds = %75
%95 = load i32, i32* %9
%96 = load i32*, i32** %8
%97 = load i64, i64* %12
%98 = mul i64 %97, 4
%99 = call i64 @send(i32 %95, i32* %96, i64 %98, i32 0)
store i64 %99, i64* %13
%100 = load i64, i64* %13
%101 = load i64, i64* %12
%102 = mul i64 %101, 4
%103 = icmp ne i64 %100, %102
br i1 %103, label %104, label %117
104: ; preds = %94
%105 = call i32 @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0))
%106 = load i32, i32* %9
%107 = load i32, i32* @SHUT_RDWR
%108 = call i32 @shutdown(i32 %106, i32 %107)
%109 = load i32, i32* %9
%110 = call i32 @close(i32 %109)
%111 = load i32*, i32** %8
%112 = call i32 @free(i32* %111)
%113 = load i32*, i32** %11
%114 = call i32 @fclose(i32* %113)
%115 = load i32, i32* @EXIT_FAILURE
%116 = sub nsw i32 0, %115
store i32 %116, i32* %4
br label %129
117: ; preds = %94
br label %70
118: ; preds = %70
%119 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0))
%120 = load i32, i32* %9
%121 = load i32, i32* @SHUT_RDWR
%122 = call i32 @shutdown(i32 %120, i32 %121)
%123 = load i32, i32* %9
%124 = call i32 @close(i32 %123)
%125 = load i32*, i32** %8
%126 = call i32 @free(i32* %125)
%127 = load i32*, i32** %11
%128 = call i32 @fclose(i32* %127)
store i32 0, i32* %4
br label %129
129: ; preds = %118, %104, %81, %41, %29, %20
%130 = load i32, i32* %4
ret i32 %130
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [36 x i8] c"Allocate application receive buffer\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [22 x i8] c"Open file for reading\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.3 = [19 x i8] c"Opening TCP socket\00"
@.str.4 = [12 x i8] c"TCP connect\00"
@.str.6 = [22 x i8] c"Failed read from file\00"
@SHUT_RDWR = global i32 0
@str = [25 x i8] c"Starting sending data...\00"
@str.9 = [26 x i8] c"Data sent. Terminating...\00"
@str.10 = [54 x i8] c"Failed to send the amount of data read from the file.\00"
define i32 @client_tcp(i8* %0, i32 %1, i8* nocapture %2) {
%4 = alloca %struct.sockaddr_in
%5 = tail call i64 @malloc(i32 4096)
%6 = inttoptr i64 %5 to i32*
%7 = icmp eq i64 %5, 0
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = tail call i32 @perror(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = sub nsw i32 0, %10
br label %87
12: ; preds = %3
%13 = tail call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = tail call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
%17 = tail call i32 @free(i32* %6)
%18 = load i32, i32* @EXIT_FAILURE
%19 = sub nsw i32 0, %18
br label %87
20: ; preds = %12
%21 = load i32, i32* @AF_INET
%22 = load i32, i32* @SOCK_STREAM
%23 = load i32, i32* @IPPROTO_TCP
%24 = tail call i32 @socket(i32 %21, i32 %22, i32 %23)
%25 = icmp eq i32 %24, -1
br i1 %25, label %26, label %32
26: ; preds = %20
%27 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
%28 = tail call i32 @free(i32* %6)
%29 = tail call i32 @fclose(i32* %13)
%30 = load i32, i32* @EXIT_FAILURE
%31 = sub nsw i32 0, %30
br label %87
32: ; preds = %20
%33 = bitcast %struct.sockaddr_in* %4 to i8*
%34 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 12)
%35 = load i32, i32* @AF_INET
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %35, i32* %36
%37 = call i32 @htons(i32 %1)
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %37, i32* %38
%39 = call i32 @inet_addr(i8* %0)
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i32 %39, i32* %40
%41 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%42 = call i32 @connect(i32 %24, %struct.sockaddr* %41, i32 12)
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %48
44: ; preds = %32
%45 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%46 = load i32, i32* @EXIT_FAILURE
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %32
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
br label %50
50: ; preds = %65, %48
%51 = call i32 @feof(i32* %13)
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %78
53: ; preds = %50
%54 = call i64 @fread(i32* %6, i32 4, i32 4096, i32* %13)
%55 = icmp eq i64 %54, 0
br i1 %55, label %56, label %65
56: ; preds = %53
%57 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%58 = load i32, i32* @SHUT_RDWR
%59 = call i32 @shutdown(i32 %24, i32 %58)
%60 = call i32 @close(i32 %24)
%61 = call i32 @free(i32* %6)
%62 = call i32 @fclose(i32* %13)
%63 = load i32, i32* @EXIT_FAILURE
%64 = sub nsw i32 0, %63
br label %85
65: ; preds = %53
%66 = shl i64 %54, 2
%67 = call i64 @send(i32 %24, i32* %6, i64 %66, i32 0)
%68 = icmp eq i64 %67, %66
br i1 %68, label %50, label %69
69: ; preds = %65
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.10, i64 0, i64 0))
%71 = load i32, i32* @SHUT_RDWR
%72 = call i32 @shutdown(i32 %24, i32 %71)
%73 = call i32 @close(i32 %24)
%74 = call i32 @free(i32* %6)
%75 = call i32 @fclose(i32* %13)
%76 = load i32, i32* @EXIT_FAILURE
%77 = sub nsw i32 0, %76
br label %85
78: ; preds = %50
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.9, i64 0, i64 0))
%80 = load i32, i32* @SHUT_RDWR
%81 = call i32 @shutdown(i32 %24, i32 %80)
%82 = call i32 @close(i32 %24)
%83 = call i32 @free(i32* %6)
%84 = call i32 @fclose(i32* %13)
br label %85
85: ; preds = %78, %69, %56
%86 = phi i32 [ %64, %56 ], [ %77, %69 ], [ 0, %78 ]
br label %87
87: ; preds = %85, %26, %15, %8
%88 = phi i32 [ %31, %26 ], [ %86, %85 ], [ %19, %15 ], [ %11, %8 ]
ret i32 %88
}