#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 */
typedef void *uint16_t;
struct timeval {
  void *tv_sec;
};
struct sockaddr_in {
  int dummy;
};
struct sockaddr {
  int dummy;
};
typedef int ssize_t;
typedef int socklen_t;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ EX_USAGE;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ MSG_WAITALL;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ err(int, char *);
int /*<<< orphan*/ errx(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ log_packet(struct sockaddr_in *, int, int);
int /*<<< orphan*/ memset(struct timeval *, int /*<<< orphan*/, int);
int recvfrom(int, char *, size_t, int /*<<< orphan*/, struct sockaddr *, int *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int sendto(int, char *, size_t, int /*<<< orphan*/, struct sockaddr const *,
           int);
int /*<<< orphan*/ snprintf(char *, int, char *, int /*<<< orphan*/,
                            int /*<<< orphan*/, char *);
size_t strlen(char *);
void *strtol(char *, char **, int);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int udp_listen(void *);
int main(int argc, char *argv[]) {
  if (argc != 3) {
    errx(EX_USAGE, "Usage: %s <port> <interval>", argv[0]);
  }
  uint16_t port = strtol(argv[1], (char **)NULL, 10);
  struct timeval timeout;
  memset(&timeout, 0, sizeof(struct timeval));
  timeout.tv_sec = strtol(argv[2], (char **)NULL, 10);
  int s = udp_listen(port);
  struct sockaddr_in addr;
  socklen_t addr_len = sizeof(struct sockaddr_in);
  bzero(&addr, addr_len);
  ssize_t nread = 0;
  fd_set readfds;
  char buf[BUFSIZ];
  size_t buf_len = BUFSIZ;
  unsigned int count = 0;
  while (1) {
    FD_ZERO(&readfds);
    FD_SET(s, &readfds);
    if (select(s + 1, &readfds, NULL, NULL, &timeout) == -1) {
      err(1, "select");
    }
    if (FD_ISSET(s, &readfds)) {
      if ((nread = recvfrom(s, buf, buf_len - 1, MSG_WAITALL,
                            (struct sockaddr *)&addr, &addr_len)) == -1) {
        err(1, "recvfrom");
      }
      assert(nread > 0);
      assert(addr_len == sizeof(struct sockaddr_in));
      log_packet(&addr, 1, nread);
      buf[nread] = '\0';
      count = 0;
    }
    if (nread > 0) {
      char out[BUFSIZ];
      snprintf(out, BUFSIZ, "%ld: %d %s", time(NULL), count++, buf);
      size_t out_len = strlen(out);
      ssize_t nsent = 0;
      if ((nsent = sendto(s, out, out_len, 0, (const struct sockaddr *)&addr,
                          addr_len)) == -1) {
        err(1, "sendto");
      }
      assert(nsent == out_len);
      log_packet(&addr, 0, nsent);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     124f <main+0x3f>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb6(%rip),%rsi
call   1050 <errx@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,-0x94(%rbp)
mov    %eax,%esi
mov    %rsi,-0x90(%rbp)
mov    $0xa,%edx
mov    %edx,-0x84(%rbp)
call   10a0 <strtol@plt>
mov    -0x94(%rbp),%esi
mov    %rax,-0x18(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    -0x90(%rbp),%rsi
mov    -0x84(%rbp),%edx
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10a0 <strtol@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   10f0 <udp_listen@plt>
mov    %eax,-0x24(%rbp)
movl   $0x4,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    -0x28(%rbp),%rdi
call   1110 <bzero@plt>
movl   $0x0,-0x30(%rbp)
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x48(%rbp)
mov    0x2cd1(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
jmp    131a <main+0x10a>
lea    -0x34(%rbp),%rdi
call   10c0 <FD_ZERO@plt>
mov    -0x24(%rbp),%edi
lea    -0x34(%rbp),%rsi
call   1130 <FD_SET@plt>
mov    -0x24(%rbp),%edi
add    $0x1,%edi
lea    -0x34(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x20(%rbp),%r8
mov    %rcx,%rdx
call   10d0 <select@plt>
cmp    $0xffffffff,%eax
jne    1363 <main+0x153>
mov    $0x1,%edi
lea    0xcbe(%rip),%rsi
call   10e0 <err@plt>
mov    -0x24(%rbp),%edi
lea    -0x34(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     1405 <main+0x1f5>
mov    -0x80(%rbp),%rsi
mov    -0x24(%rbp),%edi
mov    -0x50(%rbp),%rdx
sub    $0x1,%rdx
mov    0x2c39(%rip),%rax
mov    (%rax),%ecx
lea    -0x28(%rbp),%r8
lea    -0x2c(%rbp),%r9
call   1100 <recvfrom@plt>
mov    %eax,-0x30(%rbp)
cmp    $0xffffffff,%eax
jne    13bb <main+0x1ab>
mov    $0x1,%edi
lea    0xc6d(%rip),%rsi
call   10e0 <err@plt>
cmpl   $0x0,-0x30(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
movslq -0x2c(%rbp),%rax
cmp    $0x4,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x30(%rbp),%edx
lea    -0x28(%rbp),%rdi
mov    $0x1,%esi
call   1120 <log_packet@plt>
mov    -0x80(%rbp),%rax
movslq -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
movl   $0x0,-0x54(%rbp)
cmpl   $0x0,-0x30(%rbp)
jle    14fd <main+0x2ed>
mov    0x2bc2(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x60(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0xa0(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
mov    0x2b93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xa4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <time@plt>
mov    -0xa4(%rbp),%esi
mov    -0x80(%rbp),%r9
mov    -0xa0(%rbp),%rdi
mov    %eax,%ecx
mov    -0x54(%rbp),%r8d
mov    %r8d,%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
lea    0xbaf(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xa0(%rbp),%rsi
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x24(%rbp),%edi
mov    -0x70(%rbp),%rdx
lea    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
xor    %ecx,%ecx
call   1080 <sendto@plt>
mov    %eax,-0x74(%rbp)
cmp    $0xffffffff,%eax
jne    14d3 <main+0x2c3>
mov    $0x1,%edi
lea    0xb69(%rip),%rsi
call   10e0 <err@plt>
movslq -0x74(%rbp),%rax
cmp    -0x70(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1090 <assert@plt>
mov    -0x74(%rbp),%edx
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
call   1120 <log_packet@plt>
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
jmp    1315 <main+0x105>

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
je     1241 <main+0x31>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xdc4(%rip),%rsi
call   1050 <errx@plt>
mov    0x8(%rbx),%rdi
xor    %r15d,%r15d
xor    %esi,%esi
mov    $0xa,%edx
call   10a0 <strtol@plt>
mov    %rax,%r14
lea    -0x58(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1070 <memset@plt>
mov    0x10(%rbx),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10a0 <strtol@plt>
mov    %rax,-0x58(%rbp)
mov    %r14,%rdi
call   10f0 <udp_listen@plt>
mov    %eax,%r14d
movl   $0x4,-0x2c(%rbp)
lea    -0x38(%rbp),%r13
mov    %r13,%rdi
mov    $0x4,%esi
call   1110 <bzero@plt>
mov    0x2d33(%rip),%rax
movslq (%rax),%rcx
mov    %ecx,%eax
mov    %rsp,%rdx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,-0x50(%rbp)
mov    %rdx,%rsp
mov    %r14d,%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x60(%rbp)
lea    -0x44(%rbp),%r12
movl   $0x0,-0x30(%rbp)
mov    %r14d,-0x3c(%rbp)
jmp    131e <main+0x10e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
movslq %r14d,%rax
xor    %edi,%edi
cmp    %rax,%r12
sete   %dil
call   1090 <assert@plt>
mov    %r13,%rdi
xor    %esi,%esi
mov    %r14d,%edx
call   1120 <log_packet@plt>
mov    -0x68(%rbp),%rsp
mov    -0x3c(%rbp),%r14d
lea    -0x44(%rbp),%r12
mov    %r12,%rdi
call   10c0 <FD_ZERO@plt>
mov    %r14d,%edi
mov    %r12,%rsi
call   1130 <FD_SET@plt>
mov    -0x40(%rbp),%edi
mov    %r12,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
lea    -0x58(%rbp),%r8
call   10d0 <select@plt>
cmp    $0xffffffff,%eax
jne    135a <main+0x14a>
mov    $0x1,%edi
lea    0xcc7(%rip),%rsi
call   10e0 <err@plt>
mov    %r14d,%edi
mov    %r12,%rsi
call   1030 <FD_ISSET@plt>
test   %rax,%rax
je     13de <main+0x1ce>
mov    0x2c57(%rip),%rax
mov    (%rax),%ecx
mov    %r14d,%edi
mov    -0x50(%rbp),%r15
mov    %r15,%rsi
mov    -0x60(%rbp),%rdx
mov    %r13,%r8
lea    -0x2c(%rbp),%r9
call   1100 <recvfrom@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    13a5 <main+0x195>
mov    $0x1,%edi
lea    0xc83(%rip),%rsi
call   10e0 <err@plt>
xor    %edi,%edi
test   %ebx,%ebx
setg   %dil
call   1090 <assert@plt>
xor    %edi,%edi
cmpl   $0x4,-0x2c(%rbp)
sete   %dil
call   1090 <assert@plt>
mov    %r13,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
call   1120 <log_packet@plt>
mov    %ebx,-0x30(%rbp)
movslq %ebx,%rax
movb   $0x0,(%r15,%rax,1)
xor    %r15d,%r15d
cmpl   $0x0,-0x30(%rbp)
jle    131e <main+0x10e>
mov    %rsp,-0x68(%rbp)
mov    0x2be5(%rip),%rcx
mov    (%rcx),%eax
mov    %rsp,%rbx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    (%rcx),%r13d
xor    %edi,%edi
call   10b0 <time@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
lea    0xc0f(%rip),%rdx
mov    %eax,%ecx
mov    %r15d,%r8d
mov    -0x50(%rbp),%r9
call   1060 <snprintf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %rax,%r12
mov    -0x2c(%rbp),%r9d
mov    %r14d,%edi
mov    %rbx,%rsi
lea    -0x38(%rbp),%r13
mov    %rax,%rdx
xor    %ecx,%ecx
mov    %r13,%r8
call   1080 <sendto@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    12f0 <main+0xe0>
mov    $0x1,%edi
lea    0xbce(%rip),%rsi
call   10e0 <err@plt>
jmp    12f0 <main+0xe0>

LLVM IR (-O0):
%struct.timeval = type { i8* }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@EX_USAGE = global i32 0
@.str = [28 x i8] c"Usage: %s <port> <interval>\00"
@BUFSIZ = global i32 0
@.str.1 = [7 x i8] c"select\00"
@MSG_WAITALL = global i32 0
@.str.2 = [9 x i8] c"recvfrom\00"
@.str.3 = [11 x i8] c"%ld: %d %s\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 i8*
%7 = alloca %struct.timeval
%8 = alloca i32
%9 = alloca %struct.sockaddr_in
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca i8*
%18 = alloca i64
%19 = alloca i64
%20 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 3
br i1 %22, label %23, label %29
23: ; preds = %2
%24 = load i32, i32* @EX_USAGE
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 0
%27 = load i8*, i8** %26
%28 = call i32 @errx(i32 %24, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %27)
br label %29
29: ; preds = %23, %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i8* @strtol(i8* %32, i8** null, i32 10)
store i8* %33, i8** %6
%34 = call i32 @memset(%struct.timeval* %7, i32 0, i32 8)
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i8* @strtol(i8* %37, i8** null, i32 10)
%39 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
store i8* %38, i8** %39
%40 = load i8*, i8** %6
%41 = call i32 @udp_listen(i8* %40)
store i32 %41, i32* %8
store i32 4, i32* %10
%42 = load i32, i32* %10
%43 = call i32 @bzero(%struct.sockaddr_in* %9, i32 %42)
store i32 0, i32* %11
%44 = load i32, i32* @BUFSIZ
%45 = zext i32 %44 to i64
%46 = call i8* @llvm.stacksave()
store i8* %46, i8** %13
%47 = alloca i8, i64 %45
store i64 %45, i64* %14
%48 = load i32, i32* @BUFSIZ
%49 = sext i32 %48 to i64
store i64 %49, i64* %15
store i32 0, i32* %16
br label %50
50: ; preds = %122, %29
br label %51
51: ; preds = %50
%52 = call i32 @FD_ZERO(i32* %12)
%53 = load i32, i32* %8
%54 = call i32 @FD_SET(i32 %53, i32* %12)
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
%57 = call i32 @select(i32 %56, i32* %12, i32* null, i32* null, %struct.timeval* %7)
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %51
%60 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %61
61: ; preds = %59, %51
%62 = load i32, i32* %8
%63 = call i64 @FD_ISSET(i32 %62, i32* %12)
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %90
65: ; preds = %61
%66 = load i32, i32* %8
%67 = load i64, i64* %15
%68 = sub i64 %67, 1
%69 = load i32, i32* @MSG_WAITALL
%70 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%71 = call i32 @recvfrom(i32 %66, i8* %47, i64 %68, i32 %69, %struct.sockaddr* %70, i32* %10)
store i32 %71, i32* %11
%72 = icmp eq i32 %71, -1
br i1 %72, label %73, label %75
73: ; preds = %65
%74 = call i32 @err(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %75
75: ; preds = %73, %65
%76 = load i32, i32* %11
%77 = icmp sgt i32 %76, 0
%78 = zext i1 %77 to i32
%79 = call i32 @assert(i32 %78)
%80 = load i32, i32* %10
%81 = sext i32 %80 to i64
%82 = icmp eq i64 %81, 4
%83 = zext i1 %82 to i32
%84 = call i32 @assert(i32 %83)
%85 = load i32, i32* %11
%86 = call i32 @log_packet(%struct.sockaddr_in* %9, i32 1, i32 %85)
%87 = load i32, i32* %11
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %47, i64 %88
store i8 0, i8* %89
store i32 0, i32* %16
br label %90
90: ; preds = %75, %61
%91 = load i32, i32* %11
%92 = icmp sgt i32 %91, 0
br i1 %92, label %93, label %122
93: ; preds = %90
%94 = load i32, i32* @BUFSIZ
%95 = zext i32 %94 to i64
%96 = call i8* @llvm.stacksave()
store i8* %96, i8** %17
%97 = alloca i8, i64 %95
store i64 %95, i64* %18
%98 = load i32, i32* @BUFSIZ
%99 = call i32 @time(i32* null)
%100 = load i32, i32* %16
%101 = add i32 %100, 1
store i32 %101, i32* %16
%102 = call i32 @snprintf(i8* %97, i32 %98, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %99, i32 %100, i8* %47)
%103 = call i64 @strlen(i8* %97)
store i64 %103, i64* %19
store i32 0, i32* %20
%104 = load i32, i32* %8
%105 = load i64, i64* %19
%106 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%107 = load i32, i32* %10
%108 = call i32 @sendto(i32 %104, i8* %97, i64 %105, i32 0, %struct.sockaddr* %106, i32 %107)
store i32 %108, i32* %20
%109 = icmp eq i32 %108, -1
br i1 %109, label %110, label %112
110: ; preds = %93
%111 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %112
112: ; preds = %110, %93
%113 = load i32, i32* %20
%114 = sext i32 %113 to i64
%115 = load i64, i64* %19
%116 = icmp eq i64 %114, %115
%117 = zext i1 %116 to i32
%118 = call i32 @assert(i32 %117)
%119 = load i32, i32* %20
%120 = call i32 @log_packet(%struct.sockaddr_in* %9, i32 0, i32 %119)
%121 = load i8*, i8** %17
br label %122
122: ; preds = %112, %90
br label %50
}

LLVM IR (-O2):
%struct.timeval = type { i8* }
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@EX_USAGE = global i32 0
@.str = [28 x i8] c"Usage: %s <port> <interval>\00"
@BUFSIZ = global i32 0
@.str.1 = [7 x i8] c"select\00"
@MSG_WAITALL = global i32 0
@.str.2 = [9 x i8] c"recvfrom\00"
@.str.3 = [11 x i8] c"%ld: %d %s\00"
@.str.4 = [7 x i8] c"sendto\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.sockaddr_in
%5 = alloca i32
%6 = alloca i32
%7 = icmp eq i32 %0, 3
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = load i32, i32* @EX_USAGE
%10 = load i8*, i8** %1
%11 = tail call i32 @errx(i32 %9, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %12
12: ; preds = %8, %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i8* @strtol(i8* nocapture %14, i8** null, i32 10)
%16 = bitcast %struct.timeval* %3 to i8*
%17 = call i32 @memset(%struct.timeval* %3, i32 0, i32 8)
%18 = getelementptr inbounds i8*, i8** %1, i64 2
%19 = load i8*, i8** %18
%20 = call i8* @strtol(i8* nocapture %19, i8** null, i32 10)
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %3, i64 0, i32 0
store i8* %20, i8** %21
%22 = call i32 @udp_listen(i8* %15)
%23 = bitcast %struct.sockaddr_in* %4 to i8*
%24 = bitcast i32* %5 to i8*
store i32 4, i32* %5
%25 = call i32 @bzero(%struct.sockaddr_in* %4, i32 4)
%26 = bitcast i32* %6 to i8*
%27 = load i32, i32* @BUFSIZ
%28 = zext i32 %27 to i64
%29 = alloca i8, i64 %28
%30 = sext i32 %27 to i64
%31 = add nsw i32 %22, 1
%32 = add nsw i64 %30, -1
%33 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
br label %34
34: ; preds = %88, %12
%35 = phi i32 [ 0, %12 ], [ %89, %88 ]
%36 = phi i32 [ 0, %12 ], [ %65, %88 ]
%37 = call i32 @FD_ZERO(i32* %6)
%38 = call i32 @FD_SET(i32 %22, i32* %6)
%39 = call i32 @select(i32 %31, i32* %6, i32* null, i32* null, %struct.timeval* %3)
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %43
41: ; preds = %34
%42 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %43
43: ; preds = %41, %34
%44 = call i64 @FD_ISSET(i32 %22, i32* %6)
%45 = icmp eq i64 %44, 0
br i1 %45, label %63, label %46
46: ; preds = %43
%47 = load i32, i32* @MSG_WAITALL
%48 = call i32 @recvfrom(i32 %22, i8* %29, i64 %32, i32 %47, %struct.sockaddr* %33, i32* %5)
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = call i32 @err(i32 1, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %52
52: ; preds = %50, %46
%53 = icmp sgt i32 %48, 0
%54 = zext i1 %53 to i32
%55 = call i32 @assert(i32 %54)
%56 = load i32, i32* %5
%57 = icmp eq i32 %56, 4
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = call i32 @log_packet(%struct.sockaddr_in* %4, i32 1, i32 %48)
%61 = sext i32 %48 to i64
%62 = getelementptr inbounds i8, i8* %29, i64 %61
store i8 0, i8* %62
br label %63
63: ; preds = %52, %43
%64 = phi i32 [ 0, %52 ], [ %35, %43 ]
%65 = phi i32 [ %48, %52 ], [ %36, %43 ]
%66 = icmp sgt i32 %65, 0
br i1 %66, label %67, label %88
67: ; preds = %63
%68 = load i32, i32* @BUFSIZ
%69 = zext i32 %68 to i64
%70 = call i8* @llvm.stacksave()
%71 = alloca i8, i64 %69
%72 = load i32, i32* @BUFSIZ
%73 = call i32 @time(i32* null)
%74 = add i32 %64, 1
%75 = call i32 @snprintf(i8* %71, i32 %72, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i32 %73, i32 %64, i8* %29)
%76 = call i64 @strlen(i8* %71)
%77 = load i32, i32* %5
%78 = call i32 @sendto(i32 %22, i8* %71, i64 %76, i32 0, %struct.sockaddr* %33, i32 %77)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %67
%81 = call i32 @err(i32 1, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %82
82: ; preds = %80, %67
%83 = sext i32 %78 to i64
%84 = icmp eq i64 %76, %83
%85 = zext i1 %84 to i32
%86 = call i32 @assert(i32 %85)
%87 = call i32 @log_packet(%struct.sockaddr_in* %4, i32 0, i32 %78)
br label %88
88: ; preds = %82, %63
%89 = phi i32 [ %74, %82 ], [ %64, %63 ]
br label %34
}