#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 */

/* Type definitions */
struct sockaddr_storage {
  int dummy;
};
struct sockaddr {
  int dummy;
};
struct addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
  int /*<<< orphan*/ ai_flags;
};
typedef int socklen_t;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ AI_PASSIVE;
int /*<<< orphan*/ MSG_WAITALL;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
int bind(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
char *gai_strerror(int);
int getaddrinfo(int /*<<< orphan*/ *, char *, struct addrinfo *,
                struct addrinfo **);
int getopt(int, char **, char *);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
char *optarg;
char optopt;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  char *server_port = "1234";
  int sockfd, rc;
  int yes = 1;
  struct addrinfo hints, *server;
  char message[256];
  int o;
  while ((o = getopt(argc, argv, "p:")) != -1) {
    switch (o) {
    case 'p':
      server_port = optarg;
      break;
    case '?':
      if (optopt == 'p') {
        fprintf(stderr, "Option %c requires an argument.\n", optopt);
      } else {
        fprintf(stderr, "Unknown argument: %c.\n", optopt);
      }
      break;
    }
  }
  printf("receiving from port: %s\n", server_port);
  memset(&hints, 0, sizeof hints);
  hints.ai_family = AF_INET;
  hints.ai_socktype = SOCK_DGRAM;
  hints.ai_flags = AI_PASSIVE;
  if ((rc = getaddrinfo(NULL, server_port, &hints, &server)) != 0) {
    perror(gai_strerror(rc));
    exit(-1);
  }
  sockfd = socket(server->ai_family, server->ai_socktype, server->ai_protocol);
  if (sockfd == -1) {
    perror("ERROR opening socket");
    exit(-1);
  }
  if (setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1) {
    perror("setsockopt");
    exit(-1);
  }
  rc = bind(sockfd, server->ai_addr, server->ai_addrlen);
  if (rc == -1) {
    perror("ERROR on connect");
    close(sockfd);
    exit(-1);
  }
  while (1) {
    struct sockaddr_storage client_addr;
    socklen_t addr_size;
    int bytes_read;
    addr_size = sizeof client_addr;
    bytes_read = recvfrom(sockfd, message, sizeof message, MSG_WAITALL,
                          (struct sockaddr *)&client_addr, &addr_size);
    if (bytes_read < 0) {
      perror("ERROR recvfrom");
    }
    printf("Read: %s\n", message);
  }
out:
  freeaddrinfo(server);
  close(sockfd);
  printf("Done.\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe10(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdfc(%rip),%rdx
call   10c0 <getopt@plt>
mov    %eax,-0x154(%rbp)
cmp    $0xffffffff,%eax
je     12be <main+0xee>
mov    -0x154(%rbp),%eax
mov    %eax,-0x164(%rbp)
sub    $0x3f,%eax
je     125e <main+0x8e>
jmp    1237 <main+0x67>
mov    -0x164(%rbp),%eax
sub    $0x70,%eax
jne    12b9 <main+0xe9>
jmp    124b <main+0x7b>
mov    0x2da6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
jmp    12b9 <main+0xe9>
mov    0x2d63(%rip),%rax
movsbl (%rax),%eax
cmp    $0x70,%eax
jne    1295 <main+0xc5>
mov    0x2d38(%rip),%rax
mov    (%rax),%edi
lea    0xd87(%rip),%rsi
mov    0x2d40(%rip),%rax
movsbl (%rax),%edx
call   1080 <fprintf@plt>
jmp    12b4 <main+0xe4>
mov    0x2d14(%rip),%rax
mov    (%rax),%edi
lea    0xd84(%rip),%rsi
mov    0x2d1c(%rip),%rax
movsbl (%rax),%edx
call   1080 <fprintf@plt>
jmp    12b9 <main+0xe9>
jmp    11fb <main+0x2b>
mov    -0x18(%rbp),%rsi
lea    0xd77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
mov    0x2ce9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2ccd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    0x2cd9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
lea    -0x40(%rbp),%rdx
lea    -0x48(%rbp),%rcx
call   10e0 <getaddrinfo@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
je     133f <main+0x16f>
mov    -0x20(%rbp),%edi
call   1050 <gai_strerror@plt>
mov    %rax,%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x48(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x48(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%edx
call   10f0 <socket@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    137c <main+0x1ac>
lea    0xcec(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    0x2c5a(%rip),%rax
mov    (%rax),%esi
mov    0x2c19(%rip),%rax
mov    (%rax),%edx
lea    -0x24(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
jne    13bf <main+0x1ef>
lea    0xcbe(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
mov    -0x1c(%rbp),%edi
mov    -0x48(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x48(%rbp),%rax
mov    (%rax),%edx
call   10a0 <bind@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
jne    13ff <main+0x22f>
lea    0xc91(%rip),%rdi
call   10b0 <perror@plt>
mov    -0x1c(%rbp),%edi
call   1070 <close@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    1404 <main+0x234>
movl   $0x4,-0x15c(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x150(%rbp),%rsi
mov    0x2b79(%rip),%rax
mov    (%rax),%ecx
lea    -0x158(%rbp),%r8
mov    $0x100,%edx
lea    -0x15c(%rbp),%r9
call   1090 <recvfrom@plt>
mov    %eax,-0x160(%rbp)
cmpl   $0x0,-0x160(%rbp)
jge    1458 <main+0x288>
lea    0xc37(%rip),%rdi
call   10b0 <perror@plt>
lea    -0x150(%rbp),%rsi
lea    0xc33(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1404 <main+0x234>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movl   $0x1,0xc(%rsp)
lea    0xe0b(%rip),%rax
mov    %rax,0x10(%rsp)
lea    0xe04(%rip),%r15
mov    0x2dc0(%rip),%r14
mov    0x2da1(%rip),%r12
lea    0xe13(%rip),%r13
jmp    122b <main+0x5b>
nopl   0x0(%rax,%rax,1)
movsbl %al,%edx
mov    %r13,%rsi
call   1080 <fprintf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   10c0 <getopt@plt>
cmp    $0x3f,%eax
je     1260 <main+0x90>
cmp    $0xffffffff,%eax
je     127f <main+0xaf>
cmp    $0x70,%eax
jne    122b <main+0x5b>
mov    0x2daa(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
jmp    122b <main+0x5b>
nopl   0x0(%rax,%rax,1)
movzbl (%r14),%eax
mov    (%r12),%edi
cmp    $0x70,%al
jne    1220 <main+0x50>
lea    0xd95(%rip),%rsi
mov    $0x70,%edx
call   1080 <fprintf@plt>
jmp    122b <main+0x5b>
lea    0xdba(%rip),%rdi
mov    0x10(%rsp),%rbp
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x28(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1060 <memset@plt>
mov    0x2d20(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x38(%rsp)
mov    0x2d03(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x34(%rsp)
mov    0x2d0e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x3c(%rsp)
lea    0x18(%rsp),%rcx
xor    %edi,%edi
mov    %rbp,%rsi
mov    %rbx,%rdx
call   10e0 <getaddrinfo@plt>
test   %eax,%eax
jne    13b0 <main+0x1e0>
mov    0x18(%rsp),%rax
mov    0x10(%rax),%edi
mov    0x8(%rax),%edx
mov    0xc(%rax),%esi
call   10f0 <socket@plt>
cmp    $0xffffffff,%eax
je     13bc <main+0x1ec>
mov    %eax,%ebx
mov    0x2cd1(%rip),%rax
mov    (%rax),%esi
mov    0x2c90(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0xffffffff,%eax
je     13c5 <main+0x1f5>
mov    0x18(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebx,%edi
call   10a0 <bind@plt>
cmp    $0xffffffff,%eax
je     13db <main+0x20b>
mov    0x2c42(%rip),%r12
lea    0x40(%rsp),%rbp
lea    0x20(%rsp),%r14
lea    0x8(%rsp),%r15
lea    0xd2d(%rip),%r13
jmp    137d <main+0x1ad>
xchg   %ax,%ax
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
movl   $0x4,0x8(%rsp)
mov    (%r12),%ecx
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0x100,%edx
mov    %r14,%r8
mov    %r15,%r9
call   1090 <recvfrom@plt>
test   %eax,%eax
jns    1370 <main+0x1a0>
lea    0xce1(%rip),%rdi
call   10b0 <perror@plt>
jmp    1370 <main+0x1a0>
mov    %eax,%edi
call   1050 <gai_strerror@plt>
mov    %rax,%rdi
jmp    13cc <main+0x1fc>
lea    0xc96(%rip),%rdi
jmp    13cc <main+0x1fc>
lea    0xca2(%rip),%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
lea    0xc97(%rip),%rdi
call   10b0 <perror@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [5 x i8] c"1234\00"
@.str.1 = [3 x i8] c"p:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.2 = [33 x i8] c"Option %c requires an argument.\0A\00"
@.str.3 = [23 x i8] c"Unknown argument: %c.\0A\00"
@.str.4 = [25 x i8] c"receiving from port: %s\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@AI_PASSIVE = global i32 0
@.str.5 = [21 x i8] c"ERROR opening socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.6 = [11 x i8] c"setsockopt\00"
@.str.7 = [17 x i8] c"ERROR on connect\00"
@MSG_WAITALL = global i32 0
@.str.8 = [15 x i8] c"ERROR recvfrom\00"
@.str.9 = [10 x i8] c"Read: %s\0A\00"
@.str.10 = [7 x i8] c"Done.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.addrinfo
%11 = alloca %struct.addrinfo*
%12 = alloca [256 x i8]
%13 = alloca i32
%14 = alloca %struct.sockaddr_storage
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 1, i32* %9
br label %17
17: ; preds = %39, %2
%18 = load i32, i32* %4
%19 = load i8**, i8*** %5
%20 = call i32 @getopt(i32 %18, i8** %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 %20, i32* %13
%21 = icmp ne i32 %20, -1
br i1 %21, label %22, label %40
22: ; preds = %17
%23 = load i32, i32* %13
switch i32 %23, label %39 [
i32 112, label %24
i32 63, label %26
]
24: ; preds = %22
%25 = load i8*, i8** @optarg
store i8* %25, i8** %6
br label %39
26: ; preds = %22
%27 = load i8, i8* @optopt
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 112
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = load i8, i8* @optopt
%33 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8 signext %32)
br label %38
34: ; preds = %26
%35 = load i32, i32* @stderr
%36 = load i8, i8* @optopt
%37 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8 signext %36)
br label %38
38: ; preds = %34, %30
br label %39
39: ; preds = %22, %38, %24
br label %17
40: ; preds = %17
%41 = load i8*, i8** %6
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %41)
%43 = call i32 @memset(%struct.addrinfo* %10, i32 0, i32 24)
%44 = load i32, i32* @AF_INET
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 4
store i32 %44, i32* %45
%46 = load i32, i32* @SOCK_DGRAM
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 3
store i32 %46, i32* %47
%48 = load i32, i32* @AI_PASSIVE
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %10, i32 0, i32 5
store i32 %48, i32* %49
%50 = load i8*, i8** %6
%51 = call i32 @getaddrinfo(i32* null, i8* %50, %struct.addrinfo* %10, %struct.addrinfo** %11)
store i32 %51, i32* %8
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %58
53: ; preds = %40
%54 = load i32, i32* %8
%55 = call i8* @gai_strerror(i32 %54)
%56 = call i32 @perror(i8* %55)
%57 = call i32 @exit(i32 -1)
unreachable
58: ; preds = %40
%59 = load %struct.addrinfo*, %struct.addrinfo** %11
%60 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %59, i32 0, i32 4
%61 = load i32, i32* %60
%62 = load %struct.addrinfo*, %struct.addrinfo** %11
%63 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %62, i32 0, i32 3
%64 = load i32, i32* %63
%65 = load %struct.addrinfo*, %struct.addrinfo** %11
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i32 0, i32 2
%67 = load i32, i32* %66
%68 = call i32 @socket(i32 %61, i32 %64, i32 %67)
store i32 %68, i32* %7
%69 = load i32, i32* %7
%70 = icmp eq i32 %69, -1
br i1 %70, label %71, label %74
71: ; preds = %58
%72 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%73 = call i32 @exit(i32 -1)
unreachable
74: ; preds = %58
%75 = load i32, i32* %7
%76 = load i32, i32* @SOL_SOCKET
%77 = load i32, i32* @SO_REUSEADDR
%78 = call i32 @setsockopt(i32 %75, i32 %76, i32 %77, i32* %9, i32 4)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %83
80: ; preds = %74
%81 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%82 = call i32 @exit(i32 -1)
unreachable
83: ; preds = %74
%84 = load i32, i32* %7
%85 = load %struct.addrinfo*, %struct.addrinfo** %11
%86 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %85, i32 0, i32 1
%87 = load i32, i32* %86
%88 = load %struct.addrinfo*, %struct.addrinfo** %11
%89 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %88, i32 0, i32 0
%90 = load i32, i32* %89
%91 = call i32 @bind(i32 %84, i32 %87, i32 %90)
store i32 %91, i32* %8
%92 = load i32, i32* %8
%93 = icmp eq i32 %92, -1
br i1 %93, label %94, label %99
94: ; preds = %83
%95 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%96 = load i32, i32* %7
%97 = call i32 @close(i32 %96)
%98 = call i32 @exit(i32 -1)
unreachable
99: ; preds = %83
br label %100
100: ; preds = %99, %110
store i32 4, i32* %15
%101 = load i32, i32* %7
%102 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%103 = load i32, i32* @MSG_WAITALL
%104 = bitcast %struct.sockaddr_storage* %14 to %struct.sockaddr*
%105 = call i32 @recvfrom(i32 %101, i8* %102, i32 256, i32 %103, %struct.sockaddr* %104, i32* %15)
store i32 %105, i32* %16
%106 = load i32, i32* %16
%107 = icmp slt i32 %106, 0
br i1 %107, label %108, label %110
108: ; preds = %100
%109 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %110
110: ; preds = %108, %100
%111 = getelementptr inbounds [256 x i8], [256 x i8]* %12, i64 0, i64 0
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* %111)
br label %100
113: ; No predecessors!
%114 = load %struct.addrinfo*, %struct.addrinfo** %11
%115 = call i32 @freeaddrinfo(%struct.addrinfo* %114)
%116 = load i32, i32* %7
%117 = call i32 @close(i32 %116)
%118 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32, i32 }
%struct.sockaddr_storage = type { i32 }
%struct.sockaddr = type { i32 }
@.str = [5 x i8] c"1234\00"
@.str.1 = [3 x i8] c"p:\00"
@optarg = global i8* null
@optopt = global i8 0
@stderr = global i32 0
@.str.2 = [33 x i8] c"Option %c requires an argument.\0A\00"
@.str.3 = [23 x i8] c"Unknown argument: %c.\0A\00"
@.str.4 = [25 x i8] c"receiving from port: %s\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@AI_PASSIVE = global i32 0
@.str.5 = [21 x i8] c"ERROR opening socket\00"
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.6 = [11 x i8] c"setsockopt\00"
@.str.7 = [17 x i8] c"ERROR on connect\00"
@MSG_WAITALL = global i32 0
@.str.8 = [15 x i8] c"ERROR recvfrom\00"
@.str.9 = [10 x i8] c"Read: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca %struct.addrinfo
%5 = alloca %struct.addrinfo*
%6 = alloca [256 x i8]
%7 = alloca %struct.sockaddr_storage
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%10 = bitcast %struct.addrinfo* %4 to i8*
%11 = bitcast %struct.addrinfo** %5 to i8*
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
br label %13
13: ; preds = %18, %2
%14 = phi i8* [ %19, %18 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), %2 ]
br label %15
15: ; preds = %17, %13
%16 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
switch i32 %16, label %17 [
i32 -1, label %28
i32 112, label %18
i32 63, label %20
]
17: ; preds = %15, %24, %26
br label %15
18: ; preds = %15
%19 = load i8*, i8** @optarg
br label %13
20: ; preds = %15
%21 = load i8, i8* @optopt
%22 = icmp eq i8 %21, 112
%23 = load i32, i32* @stderr
br i1 %22, label %24, label %26
24: ; preds = %20
%25 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i8 signext 112)
br label %17
26: ; preds = %20
%27 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8 signext %21)
br label %17
28: ; preds = %15
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %14)
%30 = call i32 @memset(%struct.addrinfo* %4, i32 0, i32 24)
%31 = load i32, i32* @AF_INET
%32 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 4
store i32 %31, i32* %32
%33 = load i32, i32* @SOCK_DGRAM
%34 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 3
store i32 %33, i32* %34
%35 = load i32, i32* @AI_PASSIVE
%36 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %4, i64 0, i32 5
store i32 %35, i32* %36
%37 = call i32 @getaddrinfo(i32* null, i8* %14, %struct.addrinfo* %4, %struct.addrinfo** %5)
%38 = icmp eq i32 %37, 0
br i1 %38, label %43, label %39
39: ; preds = %28
%40 = call i8* @gai_strerror(i32 %37)
%41 = call i32 @perror(i8* %40)
%42 = call i32 @exit(i32 -1)
unreachable
43: ; preds = %28
%44 = load %struct.addrinfo*, %struct.addrinfo** %5
%45 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 4
%46 = load i32, i32* %45
%47 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 3
%48 = load i32, i32* %47
%49 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %44, i64 0, i32 2
%50 = load i32, i32* %49
%51 = call i32 @socket(i32 %46, i32 %48, i32 %50)
%52 = icmp eq i32 %51, -1
br i1 %52, label %53, label %56
53: ; preds = %43
%54 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
%55 = call i32 @exit(i32 -1)
unreachable
56: ; preds = %43
%57 = load i32, i32* @SOL_SOCKET
%58 = load i32, i32* @SO_REUSEADDR
%59 = call i32 @setsockopt(i32 %51, i32 %57, i32 %58, i32* %3, i32 4)
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0))
%63 = call i32 @exit(i32 -1)
unreachable
64: ; preds = %56
%65 = load %struct.addrinfo*, %struct.addrinfo** %5
%66 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i64 0, i32 1
%67 = load i32, i32* %66
%68 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %65, i64 0, i32 0
%69 = load i32, i32* %68
%70 = call i32 @bind(i32 %51, i32 %67, i32 %69)
%71 = icmp eq i32 %70, -1
br i1 %71, label %76, label %72
72: ; preds = %64
%73 = bitcast %struct.sockaddr_storage* %7 to i8*
%74 = bitcast i32* %8 to i8*
%75 = bitcast %struct.sockaddr_storage* %7 to %struct.sockaddr*
br label %80
76: ; preds = %64
%77 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%78 = call i32 @close(i32 %51)
%79 = call i32 @exit(i32 -1)
unreachable
80: ; preds = %72, %86
store i32 4, i32* %8
%81 = load i32, i32* @MSG_WAITALL
%82 = call i32 @recvfrom(i32 %51, i8* %12, i32 256, i32 %81, %struct.sockaddr* %75, i32* %8)
%83 = icmp slt i32 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %80
%85 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0))
br label %86
86: ; preds = %84, %80
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.9, i64 0, i64 0), i8* %12)
br label %80
}