#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 timeval {
  int tv_sec;
  scalar_t__ tv_usec;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ si_server;
typedef int /*<<< orphan*/ fd_set;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int EXIT_FAILURE;
scalar_t__ FD_ISSET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_SET(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ FD_ZERO(int /*<<< orphan*/ *);
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ htons(int);
scalar_t__ inet_aton(char *, int /*<<< orphan*/ *);
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int select(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
           int /*<<< orphan*/ *, struct timeval *);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
int /*<<< orphan*/ sleep(int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  struct sockaddr_in si_server;
  int port, s, i, slen = sizeof(si_server);
  char buf[512];
  char *srv_addr;
  fd_set readfds;
  struct timeval tv;
  int ret;
  if (argc < 3) {
    printf("Usage: %s ip_add port\n", argv[0]);
    exit(1);
  }
  port = atoi(argv[2]);
  srv_addr = argv[1];
  if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) {
    error("socket");
  }
  memset((char *)&si_server, 0, sizeof(si_server));
  si_server.sin_family = AF_INET;
  si_server.sin_port = htons(port);
  if (inet_aton(srv_addr, &si_server.sin_addr) == 0) {
    fprintf(stderr, "inet_aton() failed\n");
    exit(EXIT_FAILURE);
  }
  for (i = 0; i < 1000000; i++) {
    sprintf(buf, "DATA PACKET # %d", i);
    printf("Sending -- %s -- to %s:%d\n", buf, inet_ntoa(si_server.sin_addr),
           ntohs(si_server.sin_port));
    slen = sizeof(si_server);
    if (sendto(s, buf, 512, 0, (struct sockaddr *)&si_server, slen) == -1) {
      error("sendto()");
    }
    FD_ZERO(&readfds);
    FD_SET(s, &readfds);
    tv.tv_sec = 1;
    tv.tv_usec = 0;
    if (select(s + 1, &readfds, NULL, NULL, &tv) == -1) {
      error("select()");
    }
    if (FD_ISSET(s, &readfds)) {
      ret = recvfrom(s, buf, 512, 0, (struct sockaddr *)&si_server, &slen);
      if (ret > 0) {
        printf("Received -- %s -- from %s:%d\n", buf,
               inet_ntoa(si_server.sin_addr), ntohs(si_server.sin_port));
      }
    }
    sleep(2);
  }
  close(s);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x280,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xc,-0x30(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1289 <main+0x49>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1110 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x238(%rbp)
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
mov    0x2d28(%rip),%rax
mov    (%rax),%esi
mov    0x2cf7(%rip),%rax
mov    (%rax),%edx
call   1160 <socket@plt>
mov    %eax,-0x28(%rbp)
cmp    $0xffffffff,%eax
jne    12e0 <main+0xa0>
lea    0xd3c(%rip),%rdi
call   1100 <error@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    0x2cf1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x24(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x20(%rbp)
mov    -0x238(%rbp),%rdi
lea    -0x20(%rbp),%rsi
add    $0x4,%rsi
call   10d0 <inet_aton@plt>
cmp    $0x0,%rax
jne    1348 <main+0x108>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
lea    0xce9(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
movl   $0x0,-0x2c(%rbp)
cmpl   $0xf4240,-0x2c(%rbp)
jge    14fe <main+0x2be>
lea    -0x230(%rbp),%rdi
mov    -0x2c(%rbp),%edx
lea    0xcc5(%rip),%rsi
call   1120 <sprintf@plt>
lea    -0x230(%rbp),%rax
mov    %rax,-0x268(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x260(%rbp)
mov    -0x20(%rbp),%edi
call   10f0 <ntohs@plt>
mov    -0x268(%rbp),%rsi
mov    -0x260(%rbp),%rdx
mov    %eax,%ecx
lea    0xc95(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xc,-0x30(%rbp)
mov    -0x28(%rbp),%edi
lea    -0x230(%rbp),%rsi
lea    -0x20(%rbp),%r8
mov    -0x30(%rbp),%r9d
mov    $0x200,%edx
xor    %ecx,%ecx
call   1080 <sendto@plt>
cmp    $0xffffffff,%eax
jne    13ef <main+0x1af>
lea    0xc74(%rip),%rdi
call   1100 <error@plt>
lea    -0x23c(%rbp),%rdi
call   10b0 <FD_ZERO@plt>
mov    -0x28(%rbp),%edi
lea    -0x23c(%rbp),%rsi
call   1140 <FD_SET@plt>
movl   $0x1,-0x250(%rbp)
movq   $0x0,-0x248(%rbp)
mov    -0x28(%rbp),%edi
add    $0x1,%edi
lea    -0x23c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x250(%rbp),%r8
mov    %rcx,%rdx
call   10c0 <select@plt>
cmp    $0xffffffff,%eax
jne    1454 <main+0x214>
lea    0xc18(%rip),%rdi
call   1100 <error@plt>
mov    -0x28(%rbp),%edi
lea    -0x23c(%rbp),%rsi
call   1030 <FD_ISSET@plt>
cmp    $0x0,%rax
je     14e6 <main+0x2a6>
mov    -0x28(%rbp),%edi
lea    -0x230(%rbp),%rsi
lea    -0x20(%rbp),%r8
mov    $0x200,%edx
xor    %ecx,%ecx
lea    -0x30(%rbp),%r9
call   10e0 <recvfrom@plt>
mov    %eax,-0x254(%rbp)
cmpl   $0x0,-0x254(%rbp)
jle    14e1 <main+0x2a1>
lea    -0x230(%rbp),%rax
mov    %rax,-0x278(%rbp)
mov    -0x1c(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x270(%rbp)
mov    -0x20(%rbp),%edi
call   10f0 <ntohs@plt>
mov    -0x278(%rbp),%rsi
mov    -0x270(%rbp),%rdx
mov    %eax,%ecx
lea    0xb96(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    14e6 <main+0x2a6>
mov    $0x2,%edi
call   1150 <sleep@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    134f <main+0x10f>
mov    -0x28(%rbp),%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x280,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x238,%rsp
mov    %rsi,%rbx
movl   $0xc,0x18(%rsp)
cmp    $0x2,%edi
jle    1457 <main+0x217>
mov    0x10(%rbx),%rdi
call   1110 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%r14
mov    0x2d6d(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d5c(%rip),%rax
mov    (%rax),%esi
mov    0x2d2b(%rip),%rax
mov    (%rax),%edx
call   1160 <socket@plt>
mov    %eax,%r15d
cmp    $0xffffffff,%eax
jne    12a8 <main+0x68>
lea    0xd74(%rip),%rdi
call   1100 <error@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1070 <memset@plt>
mov    (%rbx),%eax
mov    %eax,0x10(%rsp)
mov    %ebp,%edi
call   1050 <htons@plt>
mov    %eax,0x8(%rsp)
lea    0xc(%rsp),%rsi
mov    %r14,%rdi
call   10d0 <inet_aton@plt>
test   %rax,%rax
je     1472 <main+0x232>
mov    %r15d,%ebp
add    $0x1,%ebp
lea    0x1c(%rsp),%r14
xor    %r12d,%r12d
jmp    130b <main+0xcb>
mov    $0x2,%edi
call   1150 <sleep@plt>
add    $0x1,%r12d
cmp    $0xf4240,%r12d
je     143b <main+0x1fb>
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
lea    0xd18(%rip),%rsi
mov    %r12d,%edx
call   1120 <sprintf@plt>
mov    0xc(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%r13
mov    0x8(%rsp),%edi
call   10f0 <ntohs@plt>
lea    0xd05(%rip),%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
movl   $0xc,0x18(%rsp)
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
lea    0x8(%rsp),%r8
mov    $0xc,%r9d
call   1080 <sendto@plt>
cmp    $0xffffffff,%eax
jne    1383 <main+0x143>
lea    0xce0(%rip),%rdi
call   1100 <error@plt>
mov    %r14,%rdi
call   10b0 <FD_ZERO@plt>
mov    %r15d,%edi
mov    %r14,%rsi
call   1140 <FD_SET@plt>
movl   $0x1,0x20(%rsp)
movq   $0x0,0x28(%rsp)
mov    %ebp,%edi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
lea    0x20(%rsp),%r8
call   10c0 <select@plt>
cmp    $0xffffffff,%eax
jne    13cb <main+0x18b>
lea    0xca1(%rip),%rdi
call   1100 <error@plt>
mov    %r15d,%edi
mov    %r14,%rsi
call   1030 <FD_ISSET@plt>
test   %rax,%rax
je     12f0 <main+0xb0>
mov    %r15d,%edi
lea    0x30(%rsp),%rsi
mov    $0x200,%edx
xor    %ecx,%ecx
lea    0x8(%rsp),%r8
lea    0x18(%rsp),%r9
call   10e0 <recvfrom@plt>
test   %eax,%eax
jle    12f0 <main+0xb0>
mov    0xc(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %ebp,%ebx
mov    %rax,%rbp
mov    0x8(%rsp),%edi
call   10f0 <ntohs@plt>
lea    0xc4d(%rip),%rdi
lea    0x30(%rsp),%rsi
mov    %rbp,%rdx
mov    %ebx,%ebp
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
jmp    12f0 <main+0xb0>
mov    %r15d,%edi
call   1090 <close@plt>
xor    %eax,%eax
add    $0x238,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    (%rbx),%rsi
lea    0xb9f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%edi
call   1130 <exit@plt>
mov    0x2b57(%rip),%rax
mov    (%rax),%edi
lea    0xb9c(%rip),%rsi
call   10a0 <fprintf@plt>
mov    0x2b3a(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [23 x i8] c"Usage: %s ip_add port\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@stderr = global i32 0
@.str.2 = [20 x i8] c"inet_aton() failed\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [17 x i8] c"DATA PACKET # %d\00"
@.str.4 = [27 x i8] c"Sending -- %s -- to %s:%d\0A\00"
@.str.5 = [9 x i8] c"sendto()\00"
@.str.6 = [9 x i8] c"select()\00"
@.str.7 = [30 x i8] c"Received -- %s -- from %s:%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [512 x i8]
%12 = alloca i8*
%13 = alloca i32
%14 = alloca %struct.timeval
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 12, i32* %10
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %24
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %7
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
store i8* %31, i8** %12
%32 = load i32, i32* @AF_INET
%33 = load i32, i32* @SOCK_DGRAM
%34 = load i32, i32* @IPPROTO_UDP
%35 = call i32 @socket(i32 %32, i32 %33, i32 %34)
store i32 %35, i32* %8
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %39
37: ; preds = %24
%38 = call i32 @error(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %37, %24
%40 = bitcast %struct.sockaddr_in* %6 to i8*
%41 = call i32 @memset(i8* %40, i32 0, i32 12)
%42 = load i32, i32* @AF_INET
%43 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i32 %42, i32* %43
%44 = load i32, i32* %7
%45 = call i32 @htons(i32 %44)
%46 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i32 %45, i32* %46
%47 = load i8*, i8** %12
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%49 = call i64 @inet_aton(i8* %47, i32* %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %56
51: ; preds = %39
%52 = load i32, i32* @stderr
%53 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %39
store i32 0, i32* %9
br label %57
57: ; preds = %115, %56
%58 = load i32, i32* %9
%59 = icmp slt i32 %58, 1000000
br i1 %59, label %60, label %118
60: ; preds = %57
%61 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%62 = load i32, i32* %9
%63 = call i32 @sprintf(i8* %61, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %62)
%64 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%65 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%66 = load i32, i32* %65
%67 = call i8* @inet_ntoa(i32 %66)
%68 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%69 = load i32, i32* %68
%70 = call i32 @ntohs(i32 %69)
%71 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %64, i8* %67, i32 %70)
store i32 12, i32* %10
%72 = load i32, i32* %8
%73 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%74 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%75 = load i32, i32* %10
%76 = call i32 @sendto(i32 %72, i8* %73, i32 512, i32 0, %struct.sockaddr* %74, i32 %75)
%77 = icmp eq i32 %76, -1
br i1 %77, label %78, label %80
78: ; preds = %60
%79 = call i32 @error(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %80
80: ; preds = %78, %60
%81 = call i32 @FD_ZERO(i32* %13)
%82 = load i32, i32* %8
%83 = call i32 @FD_SET(i32 %82, i32* %13)
%84 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 0
store i32 1, i32* %84
%85 = getelementptr inbounds %struct.timeval, %struct.timeval* %14, i32 0, i32 1
store i64 0, i64* %85
%86 = load i32, i32* %8
%87 = add nsw i32 %86, 1
%88 = call i32 @select(i32 %87, i32* %13, i32* null, i32* null, %struct.timeval* %14)
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %92
90: ; preds = %80
%91 = call i32 @error(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %92
92: ; preds = %90, %80
%93 = load i32, i32* %8
%94 = call i64 @FD_ISSET(i32 %93, i32* %13)
%95 = icmp ne i64 %94, 0
br i1 %95, label %96, label %113
96: ; preds = %92
%97 = load i32, i32* %8
%98 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%99 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%100 = call i32 @recvfrom(i32 %97, i8* %98, i32 512, i32 0, %struct.sockaddr* %99, i32* %10)
store i32 %100, i32* %15
%101 = load i32, i32* %15
%102 = icmp sgt i32 %101, 0
br i1 %102, label %103, label %112
103: ; preds = %96
%104 = getelementptr inbounds [512 x i8], [512 x i8]* %11, i64 0, i64 0
%105 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%106 = load i32, i32* %105
%107 = call i8* @inet_ntoa(i32 %106)
%108 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
%109 = load i32, i32* %108
%110 = call i32 @ntohs(i32 %109)
%111 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %104, i8* %107, i32 %110)
br label %112
112: ; preds = %103, %96
br label %113
113: ; preds = %112, %92
%114 = call i32 @sleep(i32 2)
br label %115
115: ; preds = %113
%116 = load i32, i32* %9
%117 = add nsw i32 %116, 1
store i32 %117, i32* %9
br label %57
118: ; preds = %57
%119 = load i32, i32* %8
%120 = call i32 @close(i32 %119)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32, i32 }
%struct.timeval = type { i32, i64 }
%struct.sockaddr = type { i32 }
@.str = [23 x i8] c"Usage: %s ip_add port\0A\00"
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.1 = [7 x i8] c"socket\00"
@stderr = global i32 0
@.str.2 = [20 x i8] c"inet_aton() failed\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [17 x i8] c"DATA PACKET # %d\00"
@.str.4 = [27 x i8] c"Sending -- %s -- to %s:%d\0A\00"
@.str.5 = [9 x i8] c"sendto()\00"
@.str.6 = [9 x i8] c"select()\00"
@.str.7 = [30 x i8] c"Received -- %s -- from %s:%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [512 x i8]
%6 = alloca i32
%7 = alloca %struct.timeval
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast i32* %4 to i8*
store i32 12, i32* %4
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%11 = bitcast i32* %6 to i8*
%12 = bitcast %struct.timeval* %7 to i8*
%13 = icmp slt i32 %0, 3
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i8*, i8** %1
%16 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32 @atoi(i8* %20)
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = load i32, i32* @AF_INET
%25 = load i32, i32* @SOCK_DGRAM
%26 = load i32, i32* @IPPROTO_UDP
%27 = tail call i32 @socket(i32 %24, i32 %25, i32 %26)
%28 = icmp eq i32 %27, -1
br i1 %28, label %29, label %31
29: ; preds = %18
%30 = tail call i32 @error(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %31
31: ; preds = %29, %18
%32 = call i32 @memset(i8* %8, i32 0, i32 12)
%33 = load i32, i32* @AF_INET
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 2
store i32 %33, i32* %34
%35 = call i32 @htons(i32 %21)
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
store i32 %35, i32* %36
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%38 = call i64 @inet_aton(i8* %23, i32* %37)
%39 = icmp eq i64 %38, 0
br i1 %39, label %45, label %40
40: ; preds = %31
%41 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 0
%43 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i64 0, i32 1
%44 = add nsw i32 %27, 1
br label %50
45: ; preds = %31
%46 = load i32, i32* @stderr
%47 = call i32 @fprintf(i32 %46, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%48 = load i32, i32* @EXIT_FAILURE
%49 = call i32 @exit(i32 %48)
unreachable
50: ; preds = %40, %81
%51 = phi i32 [ 0, %40 ], [ %83, %81 ]
%52 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %37
%54 = call i8* @inet_ntoa(i32 %53)
%55 = load i32, i32* %36
%56 = call i32 @ntohs(i32 %55)
%57 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0), i8* %10, i8* %54, i32 %56)
store i32 12, i32* %4
%58 = call i32 @sendto(i32 %27, i8* %10, i32 512, i32 0, %struct.sockaddr* %41, i32 12)
%59 = icmp eq i32 %58, -1
br i1 %59, label %60, label %62
60: ; preds = %50
%61 = call i32 @error(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
br label %62
62: ; preds = %60, %50
%63 = call i32 @FD_ZERO(i32* %6)
%64 = call i32 @FD_SET(i32 %27, i32* %6)
store i32 1, i32* %42
store i64 0, i64* %43
%65 = call i32 @select(i32 %44, i32* %6, i32* null, i32* null, %struct.timeval* %7)
%66 = icmp eq i32 %65, -1
br i1 %66, label %67, label %69
67: ; preds = %62
%68 = call i32 @error(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %69
69: ; preds = %67, %62
%70 = call i64 @FD_ISSET(i32 %27, i32* %6)
%71 = icmp eq i64 %70, 0
br i1 %71, label %81, label %72
72: ; preds = %69
%73 = call i32 @recvfrom(i32 %27, i8* %10, i32 512, i32 0, %struct.sockaddr* %41, i32* %4)
%74 = icmp sgt i32 %73, 0
br i1 %74, label %75, label %81
75: ; preds = %72
%76 = load i32, i32* %37
%77 = call i8* @inet_ntoa(i32 %76)
%78 = load i32, i32* %36
%79 = call i32 @ntohs(i32 %78)
%80 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i8* %10, i8* %77, i32 %79)
br label %81
81: ; preds = %72, %75, %69
%82 = call i32 @sleep(i32 2)
%83 = add nuw nsw i32 %51, 1
%84 = icmp eq i32 %83, 1000000
br i1 %84, label %85, label %50
85: ; preds = %81
%86 = call i32 @close(i32 %27)
ret i32 0
}