#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;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ serv_addr;
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ SOCK_STREAM;
int atoi(char *);
int /*<<< orphan*/ bcopy(char *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ bzero(char *, long);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fread(char *, long, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
long ftell(int /*<<< orphan*/ *);
char getchar();
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
scalar_t__ malloc(long);
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int write(int, char *, long);
int main(int argc, char *argv[]) {
  printf("new version");
  int sockfd, portno, n;
  char *buffer;
  long fsize;
  FILE *f;
  memset(buffer, '\0', sizeof(buffer));
  struct sockaddr_in serv_addr;
  struct hostent *server;
  if (argc < 4) {
    fprintf(stderr, "usage %s hostname port file_to_read_from\n", argv[0]);
    exit(0);
  }
  portno = atoi(argv[2]);
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  if (sockfd < 0)
    error("ERROR opening socket");
  server = gethostbyname(argv[1]);
  if (server == NULL) {
    fprintf(stderr, "ERROR, no such host\n");
    exit(0);
  }
  bzero((char *)&serv_addr, sizeof(serv_addr));
  serv_addr.sin_family = AF_INET;
  bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr,
        server->h_length);
  serv_addr.sin_port = htons(portno);
  if (connect(sockfd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) < 0)
    error("ERROR connecting");
  printf("Connected to %s @ %s \n", argv[1], argv[2]);
  while (1) {
    printf("Will send data from %s press <ENTER> to continue.", argv[3]);
    while (getchar() != '\n')
      ;
    f = (FILE *)fopen(argv[3], "r");
    fseek(f, 0, SEEK_END);
    fsize = ftell(f);
    fseek(f, 0, SEEK_SET);
    buffer = (char *)malloc(fsize + 1);
    bzero(buffer, fsize);
    fread(buffer, fsize, 1, f);
    buffer[fsize] = 0;
    fclose(f);
    n = write(sockfd, buffer, fsize);
    if (n < 0)
      error("ERROR writing to socket");
    free(buffer);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1090 <memset@plt>
cmpl   $0x4,-0x8(%rbp)
jge    12b3 <main+0x63>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
xor    %edi,%edi
call   1150 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1140 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d16(%rip),%rax
mov    (%rax),%edi
mov    0x2cf5(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12f5 <main+0xa5>
lea    0xd46(%rip),%rdi
call   1110 <error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10b0 <gethostbyname@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    132f <main+0xdf>
mov    0x2cb8(%rip),%rax
mov    (%rax),%edi
lea    0xd2a(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
xor    %edi,%edi
call   1150 <exit@plt>
lea    -0x48(%rbp),%rdi
mov    $0xc,%esi
call   1130 <bzero@plt>
mov    0x2c9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x48(%rbp),%rsi
add    $0x4,%rsi
mov    -0x50(%rbp),%rax
mov    (%rax),%edx
call   1100 <bcopy@plt>
mov    -0x18(%rbp),%edi
call   1070 <htons@plt>
mov    %eax,-0x48(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x48(%rbp),%rsi
mov    $0xc,%edx
call   1160 <connect@plt>
cmp    $0x0,%rax
jge    1396 <main+0x146>
lea    0xccf(%rip),%rdi
call   1110 <error@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xcc4(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
lea    0xcc5(%rip),%rdi
mov    $0x0,%al
call   1080 <printf@plt>
mov    $0x0,%al
call   10a0 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     13e2 <main+0x192>
jmp    13ca <main+0x17a>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xcc9(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x2be3(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    -0x38(%rbp),%rdi
call   10d0 <ftell@plt>
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rdi
mov    0x2b9a(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    -0x30(%rbp),%rdi
add    $0x1,%rdi
call   10e0 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1130 <bzero@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rcx
mov    $0x1,%edx
call   1040 <fread@plt>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x14(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
call   1050 <write@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    14a1 <main+0x251>
lea    0xc20(%rip),%rdi
call   1110 <error@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
jmp    13b4 <main+0x164>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0xd96(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %esi,%esi
mov    $0x8,%edx
call   1090 <memset@plt>
cmp    $0x3,%ebp
jle    1417 <main+0x1c7>
mov    0x10(%rbx),%rdi
call   1140 <atoi@plt>
mov    %eax,%r14d
mov    0x2d47(%rip),%r12
mov    (%r12),%edi
mov    0x2d24(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1170 <socket@plt>
mov    %eax,%r13d
test   %eax,%eax
jns    12c0 <main+0x70>
lea    0xd7b(%rip),%rdi
call   1110 <error@plt>
mov    0x8(%rbx),%rdi
call   10b0 <gethostbyname@plt>
test   %rax,%rax
je     1438 <main+0x1e8>
mov    %rax,%rbp
lea    0x8(%rsp),%r15
mov    $0xc,%esi
mov    %r15,%rdi
call   1130 <bzero@plt>
mov    (%r12),%eax
mov    %eax,0x10(%rsp)
mov    0x8(%rbp),%rsi
lea    0xc(%rsp),%rdi
mov    0x0(%rbp),%edx
call   1100 <memmove@plt>
mov    %r14d,%edi
call   1070 <htons@plt>
mov    %eax,0x8(%rsp)
mov    %r13d,%edi
mov    %r15,%rsi
mov    $0xc,%edx
call   1160 <connect@plt>
test   %rax,%rax
jns    132d <main+0xdd>
lea    0xd38(%rip),%rdi
call   1110 <error@plt>
mov    0x8(%rbx),%rsi
mov    0x10(%rbx),%rdx
lea    0xd35(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x2c76(%rip),%r15
jmp    1358 <main+0x108>
nopl   0x0(%rax)
mov    %r12,%rdi
call   1030 <free@plt>
mov    0x18(%rbx),%rsi
lea    0xd25(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   10a0 <getchar@plt>
cmp    $0xa,%al
jne    1370 <main+0x120>
mov    0x18(%rbx),%rdi
lea    0xd34(%rip),%rsi
call   1120 <fopen@plt>
mov    %rax,%rbp
mov    0x2c53(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10f0 <fseek@plt>
mov    %rbp,%rdi
call   10d0 <ftell@plt>
mov    %rax,%r14
mov    (%r15),%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   10f0 <fseek@plt>
lea    0x1(%r14),%rdi
call   10e0 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    %r14,%rsi
call   1130 <bzero@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
mov    %rbp,%rcx
call   1040 <fread@plt>
movb   $0x0,(%r12,%r14,1)
mov    %rbp,%rdi
call   1060 <fclose@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r14,%rdx
call   1050 <write@plt>
test   %eax,%eax
jns    1350 <main+0x100>
lea    0xcaf(%rip),%rdi
call   1110 <error@plt>
jmp    1350 <main+0x100>
mov    0x2bb2(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xbe2(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
xor    %edi,%edi
call   1150 <exit@plt>
mov    0x2b91(%rip),%rax
mov    (%rax),%edi
lea    0xc03(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
xor    %edi,%edi
call   1150 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"new version\00"
@stderr = global i32 0
@.str.1 = [42 x i8] c"usage %s hostname port file_to_read_from\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [21 x i8] c"ERROR opening socket\00"
@.str.3 = [21 x i8] c"ERROR, no such host\0A\00"
@.str.4 = [17 x i8] c"ERROR connecting\00"
@.str.5 = [23 x i8] c"Connected to %s @ %s \0A\00"
@.str.6 = [50 x i8] c"Will send data from %s press <ENTER> to continue.\00"
@.str.7 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.8 = [24 x i8] c"ERROR writing to socket\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 i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i32*
%12 = alloca %struct.sockaddr_in
%13 = alloca %struct.hostent*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %9
%16 = call i32 @memset(i8* %15, i8 signext 0, i32 8)
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 4
br i1 %18, label %19, label %26
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 0)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 @atoi(i8* %29)
store i32 %30, i32* %7
%31 = load i32, i32* @AF_INET
%32 = load i32, i32* @SOCK_STREAM
%33 = call i32 @socket(i32 %31, i32 %32, i32 0)
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = icmp slt i32 %34, 0
br i1 %35, label %36, label %38
36: ; preds = %26
%37 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %38
38: ; preds = %36, %26
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 1
%41 = load i8*, i8** %40
%42 = call %struct.hostent* @gethostbyname(i8* %41)
store %struct.hostent* %42, %struct.hostent** %13
%43 = load %struct.hostent*, %struct.hostent** %13
%44 = icmp eq %struct.hostent* %43, null
br i1 %44, label %45, label %49
45: ; preds = %38
%46 = load i32, i32* @stderr
%47 = call i32 (i32, i8*, ...) @fprintf(i32 %46, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%48 = call i32 @exit(i32 0)
unreachable
49: ; preds = %38
%50 = bitcast %struct.sockaddr_in* %12 to i8*
%51 = call i32 @bzero(i8* %50, i64 12)
%52 = load i32, i32* @AF_INET
%53 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 2
store i32 %52, i32* %53
%54 = load %struct.hostent*, %struct.hostent** %13
%55 = getelementptr inbounds %struct.hostent, %struct.hostent* %54, i32 0, i32 1
%56 = load i64, i64* %55
%57 = inttoptr i64 %56 to i8*
%58 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
%59 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %58, i32 0, i32 0
%60 = bitcast i32* %59 to i8*
%61 = load %struct.hostent*, %struct.hostent** %13
%62 = getelementptr inbounds %struct.hostent, %struct.hostent* %61, i32 0, i32 0
%63 = load i32, i32* %62
%64 = call i32 @bcopy(i8* %57, i8* %60, i32 %63)
%65 = load i32, i32* %7
%66 = call i32 @htons(i32 %65)
%67 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
store i32 %66, i32* %67
%68 = load i32, i32* %6
%69 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%70 = call i64 @connect(i32 %68, %struct.sockaddr* %69, i32 12)
%71 = icmp slt i64 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %49
%73 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %74
74: ; preds = %72, %49
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = load i8**, i8*** %5
%79 = getelementptr inbounds i8*, i8** %78, i64 2
%80 = load i8*, i8** %79
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %77, i8* %80)
br label %82
82: ; preds = %74, %130
%83 = load i8**, i8*** %5
%84 = getelementptr inbounds i8*, i8** %83, i64 3
%85 = load i8*, i8** %84
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i8* %85)
br label %87
87: ; preds = %91, %82
%88 = call signext i8 (...) @getchar()
%89 = sext i8 %88 to i32
%90 = icmp ne i32 %89, 10
br i1 %90, label %91, label %92
91: ; preds = %87
br label %87
92: ; preds = %87
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 3
%95 = load i8*, i8** %94
%96 = call i64 @fopen(i8* %95, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%97 = inttoptr i64 %96 to i32*
store i32* %97, i32** %11
%98 = load i32*, i32** %11
%99 = load i32, i32* @SEEK_END
%100 = call i32 @fseek(i32* %98, i32 0, i32 %99)
%101 = load i32*, i32** %11
%102 = call i64 @ftell(i32* %101)
store i64 %102, i64* %10
%103 = load i32*, i32** %11
%104 = load i32, i32* @SEEK_SET
%105 = call i32 @fseek(i32* %103, i32 0, i32 %104)
%106 = load i64, i64* %10
%107 = add nsw i64 %106, 1
%108 = call i64 @malloc(i64 %107)
%109 = inttoptr i64 %108 to i8*
store i8* %109, i8** %9
%110 = load i8*, i8** %9
%111 = load i64, i64* %10
%112 = call i32 @bzero(i8* %110, i64 %111)
%113 = load i8*, i8** %9
%114 = load i64, i64* %10
%115 = load i32*, i32** %11
%116 = call i32 @fread(i8* %113, i64 %114, i32 1, i32* %115)
%117 = load i8*, i8** %9
%118 = load i64, i64* %10
%119 = getelementptr inbounds i8, i8* %117, i64 %118
store i8 0, i8* %119
%120 = load i32*, i32** %11
%121 = call i32 @fclose(i32* %120)
%122 = load i32, i32* %6
%123 = load i8*, i8** %9
%124 = load i64, i64* %10
%125 = call i32 @write(i32 %122, i8* %123, i64 %124)
store i32 %125, i32* %8
%126 = load i32, i32* %8
%127 = icmp slt i32 %126, 0
br i1 %127, label %128, label %130
128: ; preds = %92
%129 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %130
130: ; preds = %128, %92
%131 = load i8*, i8** %9
%132 = call i32 @free(i8* %131)
br label %82
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [12 x i8] c"new version\00"
@stderr = global i32 0
@.str.1 = [42 x i8] c"usage %s hostname port file_to_read_from\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.2 = [21 x i8] c"ERROR opening socket\00"
@.str.3 = [21 x i8] c"ERROR, no such host\0A\00"
@.str.4 = [17 x i8] c"ERROR connecting\00"
@.str.5 = [23 x i8] c"Connected to %s @ %s \0A\00"
@.str.6 = [50 x i8] c"Will send data from %s press <ENTER> to continue.\00"
@.str.7 = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.8 = [24 x i8] c"ERROR writing to socket\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @memset(i8* undef, i8 signext 0, i32 8)
%6 = bitcast %struct.sockaddr_in* %3 to i8*
%7 = icmp slt i32 %0, 4
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = load i8*, i8** %1
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %2
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = tail call i32 @atoi(i8* %15)
%17 = load i32, i32* @AF_INET
%18 = load i32, i32* @SOCK_STREAM
%19 = tail call i32 @socket(i32 %17, i32 %18, i32 0)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %23
23: ; preds = %21, %13
%24 = getelementptr inbounds i8*, i8** %1, i64 1
%25 = load i8*, i8** %24
%26 = tail call %struct.hostent* @gethostbyname(i8* %25)
%27 = icmp eq %struct.hostent* %26, null
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%31 = tail call i32 @exit(i32 0)
unreachable
32: ; preds = %23
%33 = call i32 @bzero(i8* %6, i64 12)
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %34, i32* %35
%36 = getelementptr inbounds %struct.hostent, %struct.hostent* %26, i64 0, i32 1
%37 = load i64, i64* %36
%38 = inttoptr i64 %37 to i8*
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1, i32 0
%40 = bitcast i32* %39 to i8*
%41 = getelementptr inbounds %struct.hostent, %struct.hostent* %26, i64 0, i32 0
%42 = load i32, i32* %41
%43 = tail call i32 @htons(i32 %16)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %43, i32* %44
%45 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%46 = call i64 @connect(i32 %19, %struct.sockaddr* %45, i32 12)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %32
%49 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %48, %32
%51 = load i8*, i8** %24
%52 = load i8*, i8** %14
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %51, i8* %52)
%54 = getelementptr inbounds i8*, i8** %1, i64 3
br label %55
55: ; preds = %81, %50
%56 = load i8*, i8** %54
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.6, i64 0, i64 0), i8* %56)
br label %58
58: ; preds = %58, %55
%59 = call signext i8 (...) @getchar()
%60 = icmp eq i8 %59, 10
br i1 %60, label %61, label %58
61: ; preds = %58
%62 = load i8*, i8** %54
%63 = call i64 @fopen(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0))
%64 = inttoptr i64 %63 to i32*
%65 = load i32, i32* @SEEK_END
%66 = call i32 @fseek(i32* %64, i32 0, i32 %65)
%67 = call i64 @ftell(i32* %64)
%68 = load i32, i32* @SEEK_SET
%69 = call i32 @fseek(i32* %64, i32 0, i32 %68)
%70 = add nsw i64 %67, 1
%71 = call i64 @malloc(i64 %70)
%72 = inttoptr i64 %71 to i8*
%73 = call i32 @bzero(i8* %72, i64 %67)
%74 = call i32 @fread(i8* %72, i64 %67, i32 1, i32* %64)
%75 = getelementptr inbounds i8, i8* %72, i64 %67
store i8 0, i8* %75
%76 = call i32 @fclose(i32* %64)
%77 = call i32 @write(i32 %19, i8* %72, i64 %67)
%78 = icmp slt i32 %77, 0
br i1 %78, label %79, label %81
79: ; preds = %61
%80 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.8, i64 0, i64 0))
br label %81
81: ; preds = %79, %61
%82 = call i32 @free(i8* %72)
br label %55
}