#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 {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  char *h_name;
};
typedef int /*<<< orphan*/ serveraddr;
typedef int /*<<< orphan*/ clientaddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct hostent *gethostbyaddr(char const *, int, int /*<<< orphan*/);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(unsigned short);
char *inet_ntoa(TYPE_1__);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int /*<<< orphan*/ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                              void const *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main(int argc, char **argv) {
  int sockfd;
  int portno;
  int clientlen;
  struct sockaddr_in serveraddr;
  struct sockaddr_in clientaddr;
  struct hostent *hostp;
  char buf[1024];
  char *hostaddrp;
  int optval;
  int n;
  if (argc != 2) {
    fprintf(stderr, "usage: %s <port>\n", argv[0]);
    exit(1);
  }
  portno = atoi(argv[1]);
  sockfd = socket(AF_INET, SOCK_DGRAM, 0);
  if (sockfd < 0)
    error("ERROR opening socket");
  optval = 1;
  setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (const void *)&optval,
             sizeof(int));
  bzero((char *)&serveraddr, sizeof(serveraddr));
  serveraddr.sin_family = AF_INET;
  serveraddr.sin_addr.s_addr = htonl(INADDR_ANY);
  serveraddr.sin_port = htons((unsigned short)portno);
  if (bind(sockfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) < 0)
    error("ERROR on binding");
  clientlen = sizeof(clientaddr);
  while (1) {
    bzero(buf, 1024);
    n = recvfrom(sockfd, buf, 1024, 0, (struct sockaddr *)&clientaddr,
                 &clientlen);
    if (n < 0)
      error("ERROR in recvfrom");
    hostp = gethostbyaddr((const char *)&clientaddr.sin_addr.s_addr,
                          sizeof(clientaddr.sin_addr.s_addr), AF_INET);
    if (hostp == NULL)
      error("ERROR on gethostbyaddr");
    hostaddrp = inet_ntoa(clientaddr.sin_addr);
    if (hostaddrp == NULL)
      error("ERROR on inet_ntoa\n");
    printf("server received datagram from %s (%s)\n", hostp->h_name, hostaddrp);
    printf("server received %d/%d bytes: %s\n", strlen(buf), n, buf);
    n = sendto(sockfd, buf, strlen(buf), 0, (struct sockaddr *)&clientaddr,
               clientlen);
    if (n < 0)
      error("ERROR in sendto");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1249 <main+0x49>
mov    0x2d96(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdc6(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x18(%rbp)
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
mov    0x2d67(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    128b <main+0x8b>
lea    0xd8c(%rip),%rdi
call   10d0 <error@plt>
movl   $0x1,-0x44c(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d49(%rip),%rax
mov    (%rax),%esi
mov    0x2d10(%rip),%rax
mov    (%rax),%edx
lea    -0x44c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
lea    -0x28(%rbp),%rdi
mov    $0xc,%esi
call   10e0 <bzero@plt>
mov    0x2d0f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
movzwl %ax,%edi
call   1060 <htons@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
lea    -0x28(%rbp),%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
cmp    $0x0,%rax
jge    131c <main+0x11c>
lea    0xd10(%rip),%rdi
call   10d0 <error@plt>
movl   $0xc,-0x1c(%rbp)
lea    -0x440(%rbp),%rdi
mov    $0x400,%esi
call   10e0 <bzero@plt>
mov    -0x14(%rbp),%edi
lea    -0x440(%rbp),%rsi
lea    -0x38(%rbp),%r8
mov    $0x400,%edx
xor    %ecx,%ecx
lea    -0x1c(%rbp),%r9
call   10b0 <recvfrom@plt>
mov    %eax,-0x450(%rbp)
cmpl   $0x0,-0x450(%rbp)
jge    1371 <main+0x171>
lea    0xccc(%rip),%rdi
call   10d0 <error@plt>
lea    -0x38(%rbp),%rdi
mov    0x2c64(%rip),%rax
mov    (%rax),%edx
mov    $0x4,%esi
call   1100 <gethostbyaddr@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    13a3 <main+0x1a3>
lea    0xcac(%rip),%rdi
call   10d0 <error@plt>
mov    -0x38(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x448(%rbp)
cmpq   $0x0,-0x448(%rbp)
jne    13cc <main+0x1cc>
lea    0xc9a(%rip),%rdi
call   10d0 <error@plt>
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
mov    -0x448(%rbp),%rdx
lea    0xc94(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
lea    -0x440(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%esi
mov    -0x450(%rbp),%edx
lea    -0x440(%rbp),%rcx
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x45c(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x458(%rbp)
lea    -0x440(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x45c(%rbp),%edi
mov    -0x458(%rbp),%rsi
mov    %eax,%edx
lea    -0x38(%rbp),%r8
mov    -0x1c(%rbp),%r9d
xor    %ecx,%ecx
call   1090 <sendto@plt>
mov    %eax,-0x450(%rbp)
cmpl   $0x0,-0x450(%rbp)
jge    1471 <main+0x271>
lea    0xc51(%rip),%rdi
call   10d0 <error@plt>
jmp    1323 <main+0x123>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
cmp    $0x2,%edi
jne    13fe <main+0x1fe>
mov    0x8(%rsi),%rdi
call   10f0 <atoi@plt>
mov    %eax,%r14d
mov    0x2db3(%rip),%r12
mov    (%r12),%edi
mov    0x2d98(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    1254 <main+0x54>
lea    0xdc3(%rip),%rdi
call   10d0 <error@plt>
movl   $0x1,0xc(%rsp)
mov    0x2d85(%rip),%rax
mov    (%rax),%esi
mov    0x2d4c(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %r15d,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xc,%esi
call   10e0 <bzero@plt>
mov    (%r12),%eax
mov    %eax,0x18(%rsp)
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,0x10(%rsp)
movzwl %r14w,%edi
call   1060 <htons@plt>
mov    %eax,0x14(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0xc,%edx
call   10c0 <bind@plt>
test   %rax,%rax
jns    12db <main+0xdb>
lea    0xd51(%rip),%rdi
call   10d0 <error@plt>
movl   $0xc,0x4(%rsp)
lea    0x30(%rsp),%rbp
lea    0x20(%rsp),%rbx
mov    %r15d,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbp,%rdi
mov    $0x400,%esi
call   10e0 <bzero@plt>
mov    %r15d,%edi
mov    %rbp,%r14
mov    %rbp,%rsi
mov    $0x400,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
lea    0x4(%rsp),%r9
call   10b0 <recvfrom@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    133d <main+0x13d>
lea    0xd00(%rip),%rdi
call   10d0 <error@plt>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    $0x4,%esi
call   1100 <gethostbyaddr@plt>
mov    %rax,%r13
test   %rax,%rax
jne    1362 <main+0x162>
lea    0xced(%rip),%rdi
call   10d0 <error@plt>
mov    0x20(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%r12
test   %rax,%rax
jne    137f <main+0x17f>
lea    0xce7(%rip),%rdi
call   10d0 <error@plt>
mov    0x0(%r13),%rsi
lea    0xceb(%rip),%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rbp
mov    %r14,%rdi
call   1050 <strlen@plt>
lea    0xcf6(%rip),%rdi
mov    %eax,%esi
mov    %r15d,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    0x4(%rsp),%r9d
mov    0x8(%rsp),%r15d
mov    %r15d,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
lea    0x20(%rsp),%rbx
mov    %rbx,%r8
call   1090 <sendto@plt>
test   %eax,%eax
mov    0x2bf9(%rip),%r12
jns    1300 <main+0x100>
lea    0xcc9(%rip),%rdi
call   10d0 <error@plt>
jmp    1300 <main+0x100>
mov    0x2bbb(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xbef(%rip),%rsi
call   10a0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.hostent = type { i8* }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [18 x i8] c"usage: %s <port>\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [21 x i8] c"ERROR opening socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@INADDR_ANY = global i32 0
@.str.2 = [17 x i8] c"ERROR on binding\00"
@.str.3 = [18 x i8] c"ERROR in recvfrom\00"
@.str.4 = [23 x i8] c"ERROR on gethostbyaddr\00"
@.str.5 = [20 x i8] c"ERROR on inet_ntoa\0A\00"
@.str.6 = [39 x i8] c"server received datagram from %s (%s)\0A\00"
@.str.7 = [33 x i8] c"server received %d/%d bytes: %s\0A\00"
@.str.8 = [16 x i8] c"ERROR in 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 %struct.sockaddr_in
%10 = alloca %struct.sockaddr_in
%11 = alloca %struct.hostent*
%12 = alloca [1024 x i8]
%13 = alloca 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 %25
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 @fprintf(i32 %19, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @atoi(i8* %28)
store i32 %29, i32* %7
%30 = load i32, i32* @AF_INET
%31 = load i32, i32* @SOCK_DGRAM
%32 = call i32 @socket(i32 %30, i32 %31, i32 0)
store i32 %32, i32* %6
%33 = load i32, i32* %6
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %37
35: ; preds = %25
%36 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %37
37: ; preds = %35, %25
store i32 1, i32* %14
%38 = load i32, i32* %6
%39 = load i32, i32* @SOL_SOCKET
%40 = load i32, i32* @SO_REUSEADDR
%41 = bitcast i32* %14 to i8*
%42 = call i32 @setsockopt(i32 %38, i32 %39, i32 %40, i8* %41, i32 4)
%43 = bitcast %struct.sockaddr_in* %9 to i8*
%44 = call i32 @bzero(i8* %43, i32 12)
%45 = load i32, i32* @AF_INET
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %45, i32* %46
%47 = load i32, i32* @INADDR_ANY
%48 = call i32 @htonl(i32 %47)
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%50 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %49, i32 0, i32 0
store i32 %48, i32* %50
%51 = load i32, i32* %7
%52 = trunc i32 %51 to i16
%53 = call i32 @htons(i16 zeroext %52)
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i32 %53, i32* %54
%55 = load i32, i32* %6
%56 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%57 = call i64 @bind(i32 %55, %struct.sockaddr* %56, i32 12)
%58 = icmp slt i64 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %37
%60 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %61
61: ; preds = %59, %37
store i32 12, i32* %8
br label %62
62: ; preds = %61, %114
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%64 = call i32 @bzero(i8* %63, i32 1024)
%65 = load i32, i32* %6
%66 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%67 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%68 = call i32 @recvfrom(i32 %65, i8* %66, i32 1024, i32 0, %struct.sockaddr* %67, i32* %8)
store i32 %68, i32* %15
%69 = load i32, i32* %15
%70 = icmp slt i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %62
%72 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %73
73: ; preds = %71, %62
%74 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%75 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %74, i32 0, i32 0
%76 = bitcast i32* %75 to i8*
%77 = load i32, i32* @AF_INET
%78 = call %struct.hostent* @gethostbyaddr(i8* %76, i32 4, i32 %77)
store %struct.hostent* %78, %struct.hostent** %11
%79 = load %struct.hostent*, %struct.hostent** %11
%80 = icmp eq %struct.hostent* %79, null
br i1 %80, label %81, label %83
81: ; preds = %73
%82 = call i32 @error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %83
83: ; preds = %81, %73
%84 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%85 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %84, i32 0, i32 0
%86 = load i32, i32* %85
%87 = call i8* @inet_ntoa(i32 %86)
store i8* %87, i8** %13
%88 = load i8*, i8** %13
%89 = icmp eq i8* %88, null
br i1 %89, label %90, label %92
90: ; preds = %83
%91 = call i32 @error(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %92
92: ; preds = %90, %83
%93 = load %struct.hostent*, %struct.hostent** %11
%94 = getelementptr inbounds %struct.hostent, %struct.hostent* %93, i32 0, i32 0
%95 = load i8*, i8** %94
%96 = load i8*, i8** %13
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %95, i8* %96)
%98 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%99 = call i32 @strlen(i8* %98)
%100 = load i32, i32* %15
%101 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %99, i32 %100, i8* %101)
%103 = load i32, i32* %6
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%106 = call i32 @strlen(i8* %105)
%107 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%108 = load i32, i32* %8
%109 = call i32 @sendto(i32 %103, i8* %104, i32 %106, i32 0, %struct.sockaddr* %107, i32 %108)
store i32 %109, i32* %15
%110 = load i32, i32* %15
%111 = icmp slt i32 %110, 0
br i1 %111, label %112, label %114
112: ; preds = %92
%113 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %114
114: ; preds = %112, %92
br label %62
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
%struct.hostent = type { i8* }
@stderr = global i32 0
@.str = [18 x i8] c"usage: %s <port>\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [21 x i8] c"ERROR opening socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@INADDR_ANY = global i32 0
@.str.2 = [17 x i8] c"ERROR on binding\00"
@.str.3 = [18 x i8] c"ERROR in recvfrom\00"
@.str.4 = [23 x i8] c"ERROR on gethostbyaddr\00"
@.str.5 = [20 x i8] c"ERROR on inet_ntoa\0A\00"
@.str.6 = [39 x i8] c"server received datagram from %s (%s)\0A\00"
@.str.7 = [33 x i8] c"server received %d/%d bytes: %s\0A\00"
@.str.8 = [16 x i8] c"ERROR in sendto\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca [1024 x i8]
%7 = alloca i32
%8 = bitcast i32* %3 to i8*
%9 = bitcast %struct.sockaddr_in* %4 to i8*
%10 = bitcast %struct.sockaddr_in* %5 to i8*
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = bitcast i32* %7 to i8*
%13 = icmp eq i32 %0, 2
br i1 %13, label %19, label %14
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = load i8*, i8** %1
%17 = tail call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %2
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = tail call i32 @atoi(i8* %21)
%23 = load i32, i32* @AF_INET
%24 = load i32, i32* @SOCK_DGRAM
%25 = tail call i32 @socket(i32 %23, i32 %24, i32 0)
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %19
%28 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %19
store i32 1, i32* %7
%30 = load i32, i32* @SOL_SOCKET
%31 = load i32, i32* @SO_REUSEADDR
%32 = call i32 @setsockopt(i32 %25, i32 %30, i32 %31, i8* %12, i32 4)
%33 = call i32 @bzero(i8* %9, i32 12)
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %34, i32* %35
%36 = load i32, i32* @INADDR_ANY
%37 = call i32 @htonl(i32 %36)
%38 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i32 %37, i32* %38
%39 = trunc i32 %22 to i16
%40 = call i32 @htons(i16 zeroext %39)
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %40, i32* %41
%42 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%43 = call i64 @bind(i32 %25, %struct.sockaddr* %42, i32 12)
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %29
%46 = call i32 @error(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %47
47: ; preds = %45, %29
store i32 12, i32* %3
%48 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%49 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
br label %50
50: ; preds = %80, %47
%51 = call i32 @bzero(i8* %11, i32 1024)
%52 = call i32 @recvfrom(i32 %25, i8* %11, i32 1024, i32 0, %struct.sockaddr* %48, i32* %3)
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %50
%55 = call i32 @error(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %56
56: ; preds = %54, %50
%57 = load i32, i32* @AF_INET
%58 = call %struct.hostent* @gethostbyaddr(i8* %10, i32 4, i32 %57)
%59 = icmp eq %struct.hostent* %58, null
br i1 %59, label %60, label %62
60: ; preds = %56
%61 = call i32 @error(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
br label %62
62: ; preds = %60, %56
%63 = load i32, i32* %49
%64 = call i8* @inet_ntoa(i32 %63)
%65 = icmp eq i8* %64, null
br i1 %65, label %66, label %68
66: ; preds = %62
%67 = call i32 @error(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
br label %68
68: ; preds = %66, %62
%69 = getelementptr inbounds %struct.hostent, %struct.hostent* %58, i64 0, i32 0
%70 = load i8*, i8** %69
%71 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0), i8* %70, i8* %64)
%72 = call i32 @strlen(i8* %11)
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %72, i32 %52, i8* %11)
%74 = call i32 @strlen(i8* %11)
%75 = load i32, i32* %3
%76 = call i32 @sendto(i32 %25, i8* %11, i32 %74, i32 0, %struct.sockaddr* %48, i32 %75)
%77 = icmp slt i32 %76, 0
br i1 %77, label %78, label %80
78: ; preds = %68
%79 = call i32 @error(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %80
80: ; preds = %78, %68
br label %50
}