#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 socklen_t;
typedef int /*<<< orphan*/ slen;
typedef int /*<<< orphan*/ sa;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_SNDBUF;
int /*<<< orphan*/ bzero(char *, int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ inet_addr(char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ uip_htons(int);
int write(int, char *, int);
int main(int argc, char **argv) {
  struct sockaddr_in sa;
  int s, port, fd;
  char *ip_addr;
  int total = 0;
  if (argc != 3) {
    printf("usage: %s ipaddress filename\n", argv[0]);
    exit(1);
  }
  ip_addr = argv[1];
  port = 6510;
  if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("Can't create socket");
    exit(1);
  }
  bzero((char *)&sa, sizeof(sa));
  sa.sin_family = AF_INET;
  sa.sin_addr.s_addr = inet_addr(ip_addr);
  sa.sin_port = uip_htons(port);
  if (connect(s, (struct sockaddr *)&sa, sizeof(sa)) < 0) {
    perror("connect failed");
    exit(1);
  }
  socklen_t slen = 576 - 40;
  if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, &slen, sizeof(slen)) < 0) {
    perror("setsockopt failed");
    exit(1);
  }
  if ((fd = open(argv[2], O_RDONLY)) < 0) {
    perror("Could not open file");
    exit(1);
  }
  while (1) {
    char buf[64000];
    int len;
    len = read(fd, &buf[4], sizeof(buf) - 4);
    if (len == 0) {
      printf("File successfully sent (%d bytes)\n", total);
      len = read(s, buf, sizeof(buf));
      buf[len] = 0;
      printf("Reply: %s", buf);
      if (buf[0] != 'o' || buf[1] != 'k') {
        printf("OK                  0\n"
               "BAD_HEADER          1\n"
               "NO_SYMTAB           2\n"
               "NO_STRTAB           3\n"
               "NO_TEXT             4\n"
               "UNDEFINED           5\n"
               "UNKNOWN_SEGMENT     6\n"
               "NO_STARTPOINT       7\n"
               "TEXT_TO_LARGE       8\n"
               "DATA_TO_LARGE       9\n"
               "UNKNOWN_RELOC      10\n"
               "MULTIPLY_DEFINED   11\n");
      }
      exit(0);
    }
    total += len;
    buf[0] = len >> 8;
    buf[1] = len & 0xff;
    if (write(s, buf, len + 4) == -1) {
      perror("network send failed");
      exit(1);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xfa50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x3c(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1209 <main+0x49>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x38(%rbp)
movl   $0x196e,-0x28(%rbp)
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
mov    0x2d94(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10e0 <socket@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    1257 <main+0x97>
lea    0xdd6(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
lea    -0x20(%rbp),%rdi
mov    $0xc,%esi
call   10b0 <bzero@plt>
mov    0x2d74(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <inet_addr@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%edi
call   1080 <uip_htons@plt>
mov    %eax,-0x20(%rbp)
mov    -0x24(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0xc,%edx
call   10d0 <connect@plt>
cmp    $0x0,%rax
jge    12b9 <main+0xf9>
lea    0xd88(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x218,-0x40(%rbp)
mov    -0x24(%rbp),%edi
mov    0x2d1e(%rip),%rax
mov    (%rax),%esi
mov    0x2d05(%rip),%rax
mov    (%rax),%edx
lea    -0x40(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1304 <main+0x144>
lea    0xd4c(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    0x2cbd(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x2c(%rbp)
cmp    $0x0,%eax
jge    133c <main+0x17c>
lea    0xd26(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    1341 <main+0x181>
mov    -0x2c(%rbp),%edi
lea    -0xfa40(%rbp),%rsi
add    $0x4,%rsi
mov    $0xf9fc,%edx
call   1060 <read@plt>
mov    %eax,-0xfa44(%rbp)
cmpl   $0x0,-0xfa44(%rbp)
jne    13f0 <main+0x230>
mov    -0x3c(%rbp),%esi
lea    0xcf1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x24(%rbp),%edi
lea    -0xfa40(%rbp),%rsi
mov    $0xfa00,%edx
call   1060 <read@plt>
mov    %eax,-0xfa44(%rbp)
movslq -0xfa44(%rbp),%rax
movb   $0x0,-0xfa40(%rbp,%rax,1)
lea    -0xfa40(%rbp),%rsi
lea    0xcd6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsbl -0xfa40(%rbp),%eax
cmp    $0x6f,%eax
jne    13db <main+0x21b>
movsbl -0xfa3f(%rbp),%eax
cmp    $0x6b,%eax
je     13e9 <main+0x229>
lea    0xcb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   10c0 <exit@plt>
mov    -0xfa44(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0xfa44(%rbp),%eax
sar    $0x8,%eax
mov    %al,-0xfa40(%rbp)
mov    -0xfa44(%rbp),%eax
and    $0xff,%eax
mov    %al,-0xfa3f(%rbp)
mov    -0x24(%rbp),%edi
lea    -0xfa40(%rbp),%rsi
mov    -0xfa44(%rbp),%edx
add    $0x4,%edx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    1453 <main+0x293>
lea    0xd59(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
jmp    1341 <main+0x181>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xfa28,%rsp
mov    %rsi,%r14
cmp    $0x3,%edi
jne    1217 <main+0x47>
mov    0x8(%r14),%rbx
mov    0x2dec(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2dc2(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10f0 <socket@plt>
test   %eax,%eax
jns    1232 <main+0x62>
lea    0xe0c(%rip),%rdi
jmp    13ab <main+0x1db>
mov    (%r14),%rsi
lea    0xddf(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    %eax,%r15d
lea    0x10(%rsp),%r12
mov    %r12,%rdi
mov    $0xc,%esi
call   10c0 <bzero@plt>
mov    0x0(%rbp),%eax
mov    %eax,0x18(%rsp)
mov    %rbx,%rdi
call   1080 <inet_addr@plt>
mov    %eax,0x14(%rsp)
mov    $0x196e,%edi
call   1090 <uip_htons@plt>
mov    %eax,0x10(%rsp)
mov    %r15d,%edi
mov    %r12,%rsi
mov    $0xc,%edx
call   10e0 <connect@plt>
test   %rax,%rax
jns    1289 <main+0xb9>
lea    0xdae(%rip),%rdi
jmp    13ab <main+0x1db>
movl   $0x218,0xc(%rsp)
mov    0x2d50(%rip),%rax
mov    (%rax),%esi
mov    0x2d37(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %r15d,%edi
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
jns    12c7 <main+0xf7>
lea    0xd7f(%rip),%rdi
jmp    13ab <main+0x1db>
mov    0x10(%r14),%rdi
mov    0x2cfe(%rip),%rax
mov    (%rax),%esi
call   10a0 <open@plt>
test   %eax,%eax
jns    12e9 <main+0x119>
lea    0xd6f(%rip),%rdi
jmp    13ab <main+0x1db>
mov    %eax,%r12d
lea    0x24(%rsp),%r14
mov    %eax,%edi
mov    %r14,%rsi
mov    $0xf9fc,%edx
call   1070 <read@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1346 <main+0x176>
mov    %eax,%ebp
xor    %ebx,%ebx
lea    0x20(%rsp),%r13
nop
mov    %ebp,%eax
rol    $0x8,%ax
mov    %ax,0x20(%rsp)
lea    0x4(%rbp),%edx
mov    %r15d,%edi
mov    %r13,%rsi
call   1050 <write@plt>
cmp    $0xffffffff,%eax
je     13a4 <main+0x1d4>
add    %ebp,%ebx
mov    %r12d,%edi
mov    %r14,%rsi
mov    $0xf9fc,%edx
call   1070 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
jne    1310 <main+0x140>
lea    0xd1a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x20(%rsp),%rbx
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0xfa00,%edx
call   1070 <read@plt>
cltq
movb   $0x0,0x20(%rsp,%rax,1)
lea    0xd11(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
cmpb   $0x6f,0x20(%rsp)
jne    1391 <main+0x1c1>
cmpb   $0x6b,0x21(%rsp)
je     139d <main+0x1cd>
lea    0xd10(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    0xce9(%rip),%rdi
call   10b0 <perror@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [30 x i8] c"usage: %s ipaddress filename\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [20 x i8] c"Can't create socket\00"
@.str.2 = [15 x i8] c"connect failed\00"
@SOL_SOCKET = global i32 0
@SO_SNDBUF = global i32 0
@.str.3 = [18 x i8] c"setsockopt failed\00"
@O_RDONLY = global i32 0
@.str.4 = [20 x i8] c"Could not open file\00"
@.str.5 = [35 x i8] c"File successfully sent (%d bytes)\0A\00"
@.str.6 = [10 x i8] c"Reply: %s\00"
@.str.7 = [265 x i8] c"OK 0\0ABAD_HEADER 1\0ANO_SYMTAB 2\0ANO_STRTAB 3\0ANO_TEXT 4\0AUNDEFINED 5\0AUNKNOWN_SEGMENT 6\0ANO_STARTPOINT 7\0ATEXT_TO_LARGE 8\0ADATA_TO_LARGE 9\0AUNKNOWN_RELOC 10\0AMULTIPLY_DEFINED 11\0A\00"
@.str.8 = [20 x i8] c"network send failed\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 i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca [64000 x i8]
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %11
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 3
br i1 %16, label %17, label %23
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %10
store i32 6510, i32* %8
%27 = load i32, i32* @AF_INET
%28 = load i32, i32* @SOCK_STREAM
%29 = call i32 @socket(i32 %27, i32 %28, i32 0)
store i32 %29, i32* %7
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %23
%32 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %23
%35 = bitcast %struct.sockaddr_in* %6 to i8*
%36 = call i32 @bzero(i8* %35, i32 12)
%37 = load i32, i32* @AF_INET
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i32 %37, i32* %38
%39 = load i8*, i8** %10
%40 = call i32 @inet_addr(i8* %39)
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%42 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %41, i32 0, i32 0
store i32 %40, i32* %42
%43 = load i32, i32* %8
%44 = call i32 @uip_htons(i32 %43)
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i32 %44, i32* %45
%46 = load i32, i32* %7
%47 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%48 = call i64 @connect(i32 %46, %struct.sockaddr* %47, i32 12)
%49 = icmp slt i64 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %34
%51 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %34
store i32 536, i32* %12
%54 = load i32, i32* %7
%55 = load i32, i32* @SOL_SOCKET
%56 = load i32, i32* @SO_SNDBUF
%57 = call i64 @setsockopt(i32 %54, i32 %55, i32 %56, i32* %12, i32 4)
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %53
%60 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %53
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 2
%65 = load i8*, i8** %64
%66 = load i32, i32* @O_RDONLY
%67 = call i32 @open(i8* %65, i32 %66)
store i32 %67, i32* %9
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %62
%70 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %62
br label %73
73: ; preds = %72, %124
%74 = load i32, i32* %9
%75 = getelementptr inbounds [64000 x i8], [64000 x i8]* %13, i64 0, i64 4
%76 = call i32 @read(i32 %74, i8* %75, i32 63996)
store i32 %76, i32* %14
%77 = load i32, i32* %14
%78 = icmp eq i32 %77, 0
br i1 %78, label %79, label %103
79: ; preds = %73
%80 = load i32, i32* %11
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %80)
%82 = load i32, i32* %7
%83 = getelementptr inbounds [64000 x i8], [64000 x i8]* %13, i64 0, i64 0
%84 = call i32 @read(i32 %82, i8* %83, i32 64000)
store i32 %84, i32* %14
%85 = load i32, i32* %14
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds [64000 x i8], [64000 x i8]* %13, i64 0, i64 %86
store i8 0, i8* %87
%88 = getelementptr inbounds [64000 x i8], [64000 x i8]* %13, i64 0, i64 0
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %88)
%90 = getelementptr inbounds [64000 x i8], [64000 x i8]* %13, i64 0, i64 0
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp ne i32 %92, 111
br i1 %93, label %99, label %94
94: ; preds = %79
%95 = getelementptr inbounds [64000 x i8], [64000 x i8]* %13, i64 0, i64 1
%96 = load i8, i8* %95
%97 = sext i8 %96 to i32
%98 = icmp ne i32 %97, 107
br i1 %98, label %99, label %101
99: ; preds = %94, %79
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([265 x i8], [265 x i8]* @.str.7, i64 0, i64 0))
br label %101
101: ; preds = %99, %94
%102 = call i32 @exit(i32 0)
unreachable
103: ; preds = %73
%104 = load i32, i32* %14
%105 = load i32, i32* %11
%106 = add nsw i32 %105, %104
store i32 %106, i32* %11
%107 = load i32, i32* %14
%108 = ashr i32 %107, 8
%109 = trunc i32 %108 to i8
%110 = getelementptr inbounds [64000 x i8], [64000 x i8]* %13, i64 0, i64 0
store i8 %109, i8* %110
%111 = load i32, i32* %14
%112 = and i32 %111, 255
%113 = trunc i32 %112 to i8
%114 = getelementptr inbounds [64000 x i8], [64000 x i8]* %13, i64 0, i64 1
store i8 %113, i8* %114
%115 = load i32, i32* %7
%116 = getelementptr inbounds [64000 x i8], [64000 x i8]* %13, i64 0, i64 0
%117 = load i32, i32* %14
%118 = add nsw i32 %117, 4
%119 = call i32 @write(i32 %115, i8* %116, i32 %118)
%120 = icmp eq i32 %119, -1
br i1 %120, label %121, label %124
121: ; preds = %103
%122 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%123 = call i32 @exit(i32 1)
unreachable
124: ; preds = %103
br label %73
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [30 x i8] c"usage: %s ipaddress filename\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [20 x i8] c"Can't create socket\00"
@.str.2 = [15 x i8] c"connect failed\00"
@SOL_SOCKET = global i32 0
@SO_SNDBUF = global i32 0
@.str.3 = [18 x i8] c"setsockopt failed\00"
@O_RDONLY = global i32 0
@.str.4 = [20 x i8] c"Could not open file\00"
@.str.5 = [35 x i8] c"File successfully sent (%d bytes)\0A\00"
@.str.6 = [10 x i8] c"Reply: %s\00"
@.str.8 = [20 x i8] c"network send failed\00"
@str = [264 x i8] c"OK 0\0ABAD_HEADER 1\0ANO_SYMTAB 2\0ANO_STRTAB 3\0ANO_TEXT 4\0AUNDEFINED 5\0AUNKNOWN_SEGMENT 6\0ANO_STARTPOINT 7\0ATEXT_TO_LARGE 8\0ADATA_TO_LARGE 9\0AUNKNOWN_RELOC 10\0AMULTIPLY_DEFINED 11\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [64000 x i8]
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = icmp eq i32 %0, 3
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = tail call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @AF_INET
%16 = load i32, i32* @SOCK_STREAM
%17 = tail call i32 @socket(i32 %15, i32 %16, i32 0)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = tail call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %12
%23 = call i32 @bzero(i8* %6, i32 12)
%24 = load i32, i32* @AF_INET
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %24, i32* %25
%26 = tail call i32 @inet_addr(i8* %14)
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
store i32 %26, i32* %27
%28 = tail call i32 @uip_htons(i32 6510)
%29 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %28, i32* %29
%30 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%31 = call i64 @connect(i32 %17, %struct.sockaddr* %30, i32 12)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %22
%34 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %22
%37 = bitcast i32* %4 to i8*
store i32 536, i32* %4
%38 = load i32, i32* @SOL_SOCKET
%39 = load i32, i32* @SO_SNDBUF
%40 = call i64 @setsockopt(i32 %17, i32 %38, i32 %39, i32* %4, i32 4)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %36
%43 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%44 = call i32 @exit(i32 1)
unreachable
45: ; preds = %36
%46 = getelementptr inbounds i8*, i8** %1, i64 2
%47 = load i8*, i8** %46
%48 = load i32, i32* @O_RDONLY
%49 = call i32 @open(i8* %47, i32 %48)
%50 = icmp slt i32 %49, 0
br i1 %50, label %58, label %51
51: ; preds = %45
%52 = getelementptr inbounds [64000 x i8], [64000 x i8]* %5, i64 0, i64 0
%53 = getelementptr inbounds [64000 x i8], [64000 x i8]* %5, i64 0, i64 4
%54 = call i32 @read(i32 %49, i8* %53, i32 63996)
%55 = icmp eq i32 %54, 0
br i1 %55, label %61, label %56
56: ; preds = %51
%57 = getelementptr inbounds [64000 x i8], [64000 x i8]* %5, i64 0, i64 1
br label %78
58: ; preds = %45
%59 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %90, %51
%62 = phi i32 [ 0, %51 ], [ %91, %90 ]
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.5, i64 0, i64 0), i32 %62)
%64 = call i32 @read(i32 %17, i8* %52, i32 64000)
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [64000 x i8], [64000 x i8]* %5, i64 0, i64 %65
store i8 0, i8* %66
%67 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8* %52)
%68 = load i8, i8* %52
%69 = icmp ne i8 %68, 111
%70 = getelementptr inbounds [64000 x i8], [64000 x i8]* %5, i64 0, i64 1
%71 = load i8, i8* %70
%72 = icmp ne i8 %71, 107
%73 = select i1 %69, i1 true, i1 %72
br i1 %73, label %74, label %76
74: ; preds = %61
%75 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([264 x i8], [264 x i8]* @str, i64 0, i64 0))
br label %76
76: ; preds = %61, %74
%77 = call i32 @exit(i32 0)
unreachable
78: ; preds = %56, %90
%79 = phi i32 [ %54, %56 ], [ %92, %90 ]
%80 = phi i32 [ 0, %56 ], [ %91, %90 ]
%81 = lshr i32 %79, 8
%82 = trunc i32 %81 to i8
store i8 %82, i8* %52
%83 = trunc i32 %79 to i8
store i8 %83, i8* %57
%84 = add nsw i32 %79, 4
%85 = call i32 @write(i32 %17, i8* %52, i32 %84)
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %90
87: ; preds = %78
%88 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.8, i64 0, i64 0))
%89 = call i32 @exit(i32 1)
unreachable
90: ; preds = %78
%91 = add nsw i32 %79, %80
%92 = call i32 @read(i32 %49, i8* %53, i32 63996)
%93 = icmp eq i32 %92, 0
br i1 %93, label %61, label %78
}