#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__ {
  scalar_t__ 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;
  int /*<<< orphan*/ *h_addr_list;
};
typedef int /*<<< orphan*/ server;
typedef int /*<<< orphan*/ fd_set;
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ FD_SET(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
scalar_t__ INADDR_NONE;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
scalar_t__ inet_addr(char *);
int /*<<< orphan*/ memcpy(TYPE_1__ *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int read(int /*<<< orphan*/, char *, int);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int ac, char *av[]) {
  int sock, port, left, len;
  char *host, *cp, buf[188 * 256];
  struct sockaddr_in server;
  struct hostent *he;
  fd_set rd;
  if (ac < 3) {
    fprintf(stderr, "usage: %s address port\n", av[0]);
    return 0;
  }
  host = av[1];
  port = atoi(av[2]);
  if (port < 0 || port > 65535) {
    fprintf(stderr, "port no error [%d]\n", port);
    return -1;
  }
  sock = socket(AF_INET, SOCK_DGRAM, 0);
  if (sock == -1)
    return -2;
  memset((char *)&server, 0, sizeof(server));
  server.sin_family = AF_INET;
  server.sin_addr.s_addr = inet_addr(host);
  if (server.sin_addr.s_addr == INADDR_NONE) {
    he = gethostbyname(host);
    if (he == NULL) {
      close(sock);
      return -3;
    }
    memcpy(&(server.sin_addr), *(he->h_addr_list), he->h_length);
  }
  server.sin_port = htons(port);
  FD_ZERO(&rd);
  FD_SET(0, &rd);
  while (1) {
    if (select(1, &rd, NULL, NULL, NULL) == -1) {
      perror("select");
      break;
    }
    if ((left = read(0, buf, sizeof(buf))) <= 0) {
      perror("read");
      break;
    }
    cp = buf;
    while (left) {
      if ((len = sendto(sock, cp, left, 0, (struct sockaddr *)&server,
                        sizeof(server))) < 0) {
        perror("sendto");
        break;
      }
      left -= len;
      cp += len;
    }
  }
  close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xbc60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    123d <main+0x4d>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdd6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    147c <main+0x28c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     1270 <main+0x80>
cmpl   $0xffff,-0x18(%rbp)
jle    1296 <main+0xa6>
mov    0x2d51(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%edx
lea    0xd95(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    147c <main+0x28c>
mov    0x2d4b(%rip),%rax
mov    (%rax),%edi
mov    0x2d32(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12c8 <main+0xd8>
movl   $0xfffffffe,-0x4(%rbp)
jmp    147c <main+0x28c>
lea    -0xbc48(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    0x2d06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xbc38(%rbp)
mov    -0x28(%rbp),%rdi
call   1080 <inet_addr@plt>
mov    %rax,-0xbc40(%rbp)
mov    -0xbc40(%rbp),%rax
mov    0x2cd8(%rip),%rcx
cmp    (%rcx),%rax
jne    1369 <main+0x179>
mov    -0x28(%rbp),%rdi
call   1090 <gethostbyname@plt>
mov    %rax,-0xbc50(%rbp)
cmpq   $0x0,-0xbc50(%rbp)
jne    1343 <main+0x153>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0xfffffffd,-0x4(%rbp)
jmp    147c <main+0x28c>
lea    -0xbc48(%rbp),%rdi
add    $0x8,%rdi
mov    -0xbc50(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%esi
mov    -0xbc50(%rbp),%rax
mov    (%rax),%edx
call   10b0 <memcpy@plt>
mov    -0x18(%rbp),%edi
call   1030 <htons@plt>
mov    %eax,-0xbc48(%rbp)
lea    -0xbc54(%rbp),%rdi
call   10c0 <FD_ZERO@plt>
xor    %edi,%edi
lea    -0xbc54(%rbp),%rsi
call   1100 <FD_SET@plt>
mov    $0x1,%edi
lea    -0xbc54(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10d0 <select@plt>
cmp    $0xffffffff,%eax
jne    13c7 <main+0x1d7>
lea    0xc6f(%rip),%rdi
call   10e0 <perror@plt>
jmp    146d <main+0x27d>
lea    -0xbc30(%rbp),%rsi
xor    %edi,%edi
mov    $0xbc00,%edx
call   1070 <read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jg     13f7 <main+0x207>
lea    0xc46(%rip),%rdi
call   10e0 <perror@plt>
jmp    146d <main+0x27d>
lea    -0xbc30(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1468 <main+0x278>
mov    -0x14(%rbp),%edi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
lea    -0xbc48(%rbp),%r8
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1050 <sendto@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    1447 <main+0x257>
lea    0xbfb(%rip),%rdi
call   10e0 <perror@plt>
jmp    1468 <main+0x278>
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
jmp    1402 <main+0x212>
jmp    1391 <main+0x1a1>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xbc60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xbc28,%rsp
cmp    $0x2,%edi
jg     1228 <main+0x38>
mov    0x2dbb(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xde7(%rip),%rsi
xor    %r14d,%r14d
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    12d3 <main+0xe3>
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%rdi
call   10f0 <atoi@plt>
mov    %eax,%ebp
cmp    $0x10000,%eax
jb     125f <main+0x6f>
mov    0x2d83(%rip),%rax
mov    (%rax),%edi
lea    0xdca(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffffff,%r14d
jmp    12d3 <main+0xe3>
mov    0x2d82(%rip),%r15
mov    (%r15),%edi
mov    0x2d68(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1110 <socket@plt>
cmp    $0xffffffff,%eax
je     12cd <main+0xdd>
mov    %eax,%ebx
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
mov    (%r15),%eax
mov    %eax,0x18(%rsp)
mov    %r14,%rdi
call   1080 <inet_addr@plt>
mov    %rax,0x10(%rsp)
mov    0x2d34(%rip),%rcx
cmp    (%rcx),%rax
jne    12fa <main+0x10a>
mov    %r14,%rdi
call   1090 <gethostbyname@plt>
test   %rax,%rax
jne    12e8 <main+0xf8>
mov    %ebx,%edi
call   1060 <close@plt>
mov    $0xfffffffd,%r14d
jmp    12d3 <main+0xe3>
mov    $0xfffffffe,%r14d
mov    %r14d,%eax
add    $0xbc28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x10(%rsp),%rdi
mov    0x8(%rax),%rcx
mov    (%rcx),%esi
mov    (%rax),%edx
call   10b0 <memcpy@plt>
mov    %ebp,%edi
call   1030 <htons@plt>
mov    %eax,0x8(%rsp)
lea    0x4(%rsp),%rbp
mov    %rbp,%rdi
call   10c0 <FD_ZERO@plt>
xor    %r14d,%r14d
xor    %edi,%edi
mov    %rbp,%rsi
call   1100 <FD_SET@plt>
mov    $0x1,%edi
mov    %rbp,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10d0 <select@plt>
lea    0xcf2(%rip),%rdi
cmp    $0xffffffff,%eax
je     13d8 <main+0x1e8>
lea    0x20(%rsp),%r15
lea    0x8(%rsp),%rbp
jmp    137b <main+0x18b>
lea    0xce2(%rip),%rdi
call   10e0 <perror@plt>
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
lea    0x4(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10d0 <select@plt>
cmp    $0xffffffff,%eax
je     13c8 <main+0x1d8>
xor    %edi,%edi
mov    %r15,%rsi
mov    $0xbc00,%edx
call   1070 <read@plt>
test   %eax,%eax
jle    13d1 <main+0x1e1>
mov    %eax,%r13d
mov    %r15,%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r13d,%edx
xor    %ecx,%ecx
mov    %rbp,%r8
mov    $0x18,%r9d
call   1050 <sendto@plt>
test   %eax,%eax
js     134f <main+0x15f>
mov    %eax,%ecx
add    %rcx,%r12
sub    %eax,%r13d
jne    13a0 <main+0x1b0>
jmp    1360 <main+0x170>
lea    0xc5d(%rip),%rdi
jmp    13d8 <main+0x1e8>
lea    0xc5b(%rip),%rdi
call   10e0 <perror@plt>
mov    %ebx,%edi
call   1060 <close@plt>
jmp    12d3 <main+0xe3>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64 }
%struct.hostent = type { i32, i32* }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"usage: %s address port\0A\00"
@.str.1 = [20 x i8] c"port no error [%d]\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@INADDR_NONE = global i64 0
@.str.2 = [7 x i8] c"select\00"
@.str.3 = [5 x i8] c"read\00"
@.str.4 = [7 x i8] c"sendto\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 i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [48128 x i8]
%13 = alloca %struct.sockaddr_in
%14 = alloca %struct.hostent*
%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 slt i32 %16, 3
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 0
%22 = load i8*, i8** %21
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %22)
store i32 0, i32* %3
br label %123
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
store i8* %27, i8** %10
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @atoi(i8* %30)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %24
%35 = load i32, i32* %7
%36 = icmp sgt i32 %35, 65535
br i1 %36, label %37, label %41
37: ; preds = %34, %24
%38 = load i32, i32* @stderr
%39 = load i32, i32* %7
%40 = call i32 (i32, i8*, ...) @fprintf(i32 %38, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %39)
store i32 -1, i32* %3
br label %123
41: ; preds = %34
%42 = load i32, i32* @AF_INET
%43 = load i32, i32* @SOCK_DGRAM
%44 = call i32 @socket(i32 %42, i32 %43, i32 0)
store i32 %44, i32* %6
%45 = load i32, i32* %6
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %48
47: ; preds = %41
store i32 -2, i32* %3
br label %123
48: ; preds = %41
%49 = bitcast %struct.sockaddr_in* %13 to i8*
%50 = call i32 @memset(i8* %49, i32 0, i32 24)
%51 = load i32, i32* @AF_INET
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 2
store i32 %51, i32* %52
%53 = load i8*, i8** %10
%54 = call i64 @inet_addr(i8* %53)
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i32 0, i32 0
store i64 %54, i64* %56
%57 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
%58 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %57, i32 0, i32 0
%59 = load i64, i64* %58
%60 = load i64, i64* @INADDR_NONE
%61 = icmp eq i64 %59, %60
br i1 %61, label %62, label %80
62: ; preds = %48
%63 = load i8*, i8** %10
%64 = call %struct.hostent* @gethostbyname(i8* %63)
store %struct.hostent* %64, %struct.hostent** %14
%65 = load %struct.hostent*, %struct.hostent** %14
%66 = icmp eq %struct.hostent* %65, null
br i1 %66, label %67, label %70
67: ; preds = %62
%68 = load i32, i32* %6
%69 = call i32 @close(i32 %68)
store i32 -3, i32* %3
br label %123
70: ; preds = %62
%71 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
%72 = load %struct.hostent*, %struct.hostent** %14
%73 = getelementptr inbounds %struct.hostent, %struct.hostent* %72, i32 0, i32 1
%74 = load i32*, i32** %73
%75 = load i32, i32* %74
%76 = load %struct.hostent*, %struct.hostent** %14
%77 = getelementptr inbounds %struct.hostent, %struct.hostent* %76, i32 0, i32 0
%78 = load i32, i32* %77
%79 = call i32 @memcpy(%struct.TYPE_2__* %71, i32 %75, i32 %78)
br label %80
80: ; preds = %70, %48
%81 = load i32, i32* %7
%82 = call i32 @htons(i32 %81)
%83 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
store i32 %82, i32* %83
%84 = call i32 @FD_ZERO(i32* %15)
%85 = call i32 @FD_SET(i32 0, i32* %15)
br label %86
86: ; preds = %80, %119
%87 = call i32 @select(i32 1, i32* %15, i32* null, i32* null, i32* null)
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %91
89: ; preds = %86
%90 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %120
91: ; preds = %86
%92 = getelementptr inbounds [48128 x i8], [48128 x i8]* %12, i64 0, i64 0
%93 = call i32 @read(i32 0, i8* %92, i32 48128)
store i32 %93, i32* %8
%94 = icmp sle i32 %93, 0
br i1 %94, label %95, label %97
95: ; preds = %91
%96 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
br label %120
97: ; preds = %91
%98 = getelementptr inbounds [48128 x i8], [48128 x i8]* %12, i64 0, i64 0
store i8* %98, i8** %11
br label %99
99: ; preds = %111, %97
%100 = load i32, i32* %8
%101 = icmp ne i32 %100, 0
br i1 %101, label %102, label %119
102: ; preds = %99
%103 = load i32, i32* %6
%104 = load i8*, i8** %11
%105 = load i32, i32* %8
%106 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%107 = call i32 @sendto(i32 %103, i8* %104, i32 %105, i32 0, %struct.sockaddr* %106, i32 24)
store i32 %107, i32* %9
%108 = icmp slt i32 %107, 0
br i1 %108, label %109, label %111
109: ; preds = %102
%110 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %119
111: ; preds = %102
%112 = load i32, i32* %9
%113 = load i32, i32* %8
%114 = sub nsw i32 %113, %112
store i32 %114, i32* %8
%115 = load i32, i32* %9
%116 = load i8*, i8** %11
%117 = sext i32 %115 to i64
%118 = getelementptr inbounds i8, i8* %116, i64 %117
store i8* %118, i8** %11
br label %99
119: ; preds = %109, %99
br label %86
120: ; preds = %95, %89
%121 = load i32, i32* %6
%122 = call i32 @close(i32 %121)
store i32 0, i32* %3
br label %123
123: ; preds = %120, %67, %47, %37, %18
%124 = load i32, i32* %3
ret i32 %124
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64 }
%struct.hostent = type { i32, i32* }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [24 x i8] c"usage: %s address port\0A\00"
@.str.1 = [20 x i8] c"port no error [%d]\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@INADDR_NONE = global i64 0
@.str.2 = [7 x i8] c"select\00"
@.str.3 = [5 x i8] c"read\00"
@.str.4 = [7 x i8] c"sendto\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [48128 x i8]
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = getelementptr inbounds [48128 x i8], [48128 x i8]* %3, i64 0, i64 0
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = icmp slt i32 %0, 3
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8*, i8** %1
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %81
14: ; preds = %2
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
%20 = icmp ugt i32 %19, 65535
br i1 %20, label %21, label %24
21: ; preds = %14
%22 = load i32, i32* @stderr
%23 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %81
24: ; preds = %14
%25 = load i32, i32* @AF_INET
%26 = load i32, i32* @SOCK_DGRAM
%27 = tail call i32 @socket(i32 %25, i32 %26, i32 0)
%28 = icmp eq i32 %27, -1
br i1 %28, label %81, label %29
29: ; preds = %24
%30 = call i32 @memset(i8* %7, i32 0, i32 24)
%31 = load i32, i32* @AF_INET
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %31, i32* %32
%33 = call i64 @inet_addr(i8* %16)
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
%35 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %34, i64 0, i32 0
store i64 %33, i64* %35
%36 = load i64, i64* @INADDR_NONE
%37 = icmp eq i64 %33, %36
br i1 %37, label %38, label %50
38: ; preds = %29
%39 = call %struct.hostent* @gethostbyname(i8* %16)
%40 = icmp eq %struct.hostent* %39, null
br i1 %40, label %41, label %43
41: ; preds = %38
%42 = call i32 @close(i32 %27)
br label %81
43: ; preds = %38
%44 = getelementptr inbounds %struct.hostent, %struct.hostent* %39, i64 0, i32 1
%45 = load i32*, i32** %44
%46 = load i32, i32* %45
%47 = getelementptr inbounds %struct.hostent, %struct.hostent* %39, i64 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 @memcpy(%struct.TYPE_2__* %34, i32 %46, i32 %48)
br label %50
50: ; preds = %43, %29
%51 = call i32 @htons(i32 %19)
%52 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
store i32 %51, i32* %52
%53 = call i32 @FD_ZERO(i32* %5)
%54 = call i32 @FD_SET(i32 0, i32* %5)
%55 = call i32 @select(i32 1, i32* %5, i32* null, i32* null, i32* null)
%56 = icmp eq i32 %55, -1
br i1 %56, label %77, label %57
57: ; preds = %50
%58 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %59
59: ; preds = %57, %74
%60 = call i32 @read(i32 0, i8* %6, i32 48128)
%61 = icmp slt i32 %60, 1
br i1 %61, label %77, label %62
62: ; preds = %59, %69
%63 = phi i8* [ %72, %69 ], [ %6, %59 ]
%64 = phi i32 [ %70, %69 ], [ %60, %59 ]
%65 = call i32 @sendto(i32 %27, i8* %63, i32 %64, i32 0, %struct.sockaddr* %58, i32 24)
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %62
%68 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %74
69: ; preds = %62
%70 = sub nsw i32 %64, %65
%71 = zext i32 %65 to i64
%72 = getelementptr inbounds i8, i8* %63, i64 %71
%73 = icmp eq i32 %70, 0
br i1 %73, label %74, label %62
74: ; preds = %69, %67
%75 = call i32 @select(i32 1, i32* %5, i32* null, i32* null, i32* null)
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %59
77: ; preds = %59, %74, %50
%78 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %50 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %74 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %59 ]
%79 = call i32 @perror(i8* %78)
%80 = call i32 @close(i32 %27)
br label %81
81: ; preds = %24, %77, %41, %21, %10
%82 = phi i32 [ 0, %10 ], [ -1, %21 ], [ -3, %41 ], [ 0, %77 ], [ -2, %24 ]
ret i32 %82
}