#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_in {
  int /*<<< orphan*/ sin_addr;
  void *sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ on;
typedef int /*<<< orphan*/ buffer;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ Receiver(int);
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_BROADCAST;
int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ bzero(struct sockaddr_in *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
scalar_t__ fork();
void *htons(int);
scalar_t__ inet_aton(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ panic(char *, ...);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ sendto(int, char *, scalar_t__, int /*<<< orphan*/,
                  struct sockaddr *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int const *,
                      int);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
scalar_t__ strcmp(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strtrim(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/);
int main(int count, char *strings[]) {
  const int on = 1;
  int sd, port;
  struct sockaddr_in addr;
  char buffer[1024];
  if (count < 3 || count > 4) {
    printf("usage: %s [<listening-port>] <dest-addr> <dest-port>\n",
           strings[0]);
    return 0;
  }
  if (count == 4) {
    port = atoi(strings[1]);
    strings++;
  } else
    port = 9999;
  sd = socket(PF_INET, SOCK_DGRAM, 0);
  if (sd < 0)
    panic("socket failed");
  if (setsockopt(sd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)) != 0)
    panic("set broadcast failed");
  bzero(&addr, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_port = htons(port);
  if (inet_aton("128.1.1.1", &addr.sin_addr) == 0)
    panic("inet_aton failed (%s)", strings[1]);
  if (bind(sd, (struct sockaddr *)&addr, sizeof(addr)) != 0)
    panic("bind failed");
  addr.sin_port = htons(atoi(strings[2]));
  if (inet_aton(strings[1], &addr.sin_addr) == 0)
    panic("inet_aton failed (%s)", strings[1]);
  if (fork())
    Receiver(sd);
  else
    shutdown(sd, 0);
  do {
    fgets(buffer, sizeof(buffer), stdin);
    strtrim(buffer);
    if (sendto(sd, buffer, strlen(buffer) + 1, 0, (struct sockaddr *)&addr,
               sizeof(addr)) < 0)
      perror("sendto");
  } while (strcmp(buffer, "bye") != 0);
  wait(0);
  close(sd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x3,-0x8(%rbp)
jl     1274 <main+0x34>
cmpl   $0x4,-0x8(%rbp)
jle    1293 <main+0x53>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xd7e(%rip),%rdi
call   1070 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14e6 <main+0x2a6>
cmpl   $0x4,-0x8(%rbp)
jne    12be <main+0x7e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1130 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    12c5 <main+0x85>
movl   $0x270f,-0x1c(%rbp)
mov    0x2cec(%rip),%rax
mov    (%rax),%edi
mov    0x2cfb(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    12f9 <main+0xb9>
lea    0xd44(%rip),%rdi
mov    $0x0,%al
call   1080 <panic@plt>
mov    -0x18(%rbp),%edi
mov    0x2ce5(%rip),%rax
mov    (%rax),%esi
mov    0x2cbc(%rip),%rax
mov    (%rax),%edx
lea    -0x14(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
je     1335 <main+0xf5>
lea    0xd16(%rip),%rdi
mov    $0x0,%al
call   1080 <panic@plt>
lea    -0x38(%rbp),%rdi
mov    $0x18,%esi
call   1120 <bzero@plt>
mov    0x2c96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x1c(%rbp),%edi
call   1060 <htons@plt>
mov    %rax,-0x30(%rbp)
lea    -0x38(%rbp),%rsi
lea    0xcf3(%rip),%rdi
call   10d0 <inet_aton@plt>
cmp    $0x0,%rax
jne    138b <main+0x14b>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1080 <panic@plt>
mov    -0x18(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x18,%edx
call   1100 <bind@plt>
cmp    $0x0,%rax
je     13b4 <main+0x174>
lea    0xccc(%rip),%rdi
mov    $0x0,%al
call   1080 <panic@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1130 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x38(%rbp),%rsi
call   10d0 <inet_aton@plt>
cmp    $0x0,%rax
jne    13fd <main+0x1bd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xc6d(%rip),%rdi
mov    $0x0,%al
call   1080 <panic@plt>
mov    $0x0,%al
call   1150 <fork@plt>
cmp    $0x0,%rax
je     141b <main+0x1db>
mov    -0x18(%rbp),%edi
call   10e0 <Receiver@plt>
jmp    1425 <main+0x1e5>
mov    -0x18(%rbp),%edi
xor    %esi,%esi
call   1040 <shutdown@plt>
jmp    142a <main+0x1ea>
lea    -0x440(%rbp),%rdi
mov    0x2ba0(%rip),%rax
mov    (%rax),%edx
mov    $0x400,%esi
call   10b0 <fgets@plt>
lea    -0x440(%rbp),%rdi
call   10f0 <strtrim@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x44c(%rbp)
lea    -0x440(%rbp),%rax
mov    %rax,-0x448(%rbp)
lea    -0x440(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x44c(%rbp),%edi
mov    -0x448(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
lea    -0x38(%rbp),%r8
xor    %ecx,%ecx
mov    $0x18,%r9d
call   1090 <sendto@plt>
cmp    $0x0,%rax
jge    14ae <main+0x26e>
lea    0xbdc(%rip),%rdi
call   1110 <perror@plt>
jmp    14b3 <main+0x273>
lea    -0x440(%rbp),%rdi
lea    0xbcb(%rip),%rsi
call   10c0 <strcmp@plt>
cmp    $0x0,%rax
jne    142a <main+0x1ea>
xor    %edi,%edi
call   1140 <wait@plt>
mov    -0x18(%rbp),%edi
call   10a0 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %rsi,%r14
movl   $0x1,0x4(%rsp)
lea    -0x5(%rdi),%eax
cmp    $0xfffffffd,%eax
ja     1278 <main+0x38>
mov    (%r14),%rsi
lea    0xd92(%rip),%rdi
call   1070 <printf@plt>
jmp    1459 <main+0x219>
mov    $0x270f,%ebp
cmp    $0x4,%edi
jne    1291 <main+0x51>
mov    0x8(%r14),%rdi
add    $0x8,%r14
call   1130 <atoi@plt>
mov    %eax,%ebp
mov    0x2d20(%rip),%rax
mov    (%rax),%edi
mov    0x2d2f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,%r15d
test   %eax,%eax
jns    12bf <main+0x7f>
lea    0xd7e(%rip),%rdi
xor    %eax,%eax
call   1080 <panic@plt>
mov    0x2d22(%rip),%rax
mov    (%rax),%esi
mov    0x2cf9(%rip),%rax
mov    (%rax),%edx
lea    0x4(%rsp),%rcx
mov    %r15d,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
je     12f7 <main+0xb7>
lea    0xd54(%rip),%rdi
xor    %eax,%eax
call   1080 <panic@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x18,%esi
call   1120 <bzero@plt>
mov    0x2cd0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    %ebp,%edi
call   1060 <htons@plt>
mov    %rax,0x10(%rsp)
lea    0xd30(%rip),%rdi
mov    %rbx,%rsi
call   10d0 <inet_aton@plt>
test   %rax,%rax
jne    1348 <main+0x108>
mov    0x8(%r14),%rsi
lea    0xd22(%rip),%rdi
xor    %eax,%eax
call   1080 <panic@plt>
lea    0x8(%rsp),%rsi
mov    %r15d,%edi
mov    $0x18,%edx
call   1100 <bind@plt>
test   %rax,%rax
je     136d <main+0x12d>
lea    0xd13(%rip),%rdi
xor    %eax,%eax
call   1080 <panic@plt>
mov    0x10(%r14),%rdi
call   1130 <atoi@plt>
mov    %eax,%edi
call   1060 <htons@plt>
mov    %rax,0x10(%rsp)
mov    0x8(%r14),%rdi
lea    0x8(%rsp),%rsi
call   10d0 <inet_aton@plt>
test   %rax,%rax
jne    13a7 <main+0x167>
mov    0x8(%r14),%rsi
lea    0xcc3(%rip),%rdi
xor    %eax,%eax
call   1080 <panic@plt>
xor    %eax,%eax
call   1150 <fork@plt>
mov    %r15d,%edi
test   %rax,%rax
je     13bd <main+0x17d>
call   10e0 <Receiver@plt>
jmp    13c4 <main+0x184>
xor    %esi,%esi
call   1040 <shutdown@plt>
mov    0x2c0d(%rip),%r13
lea    0x20(%rsp),%rbp
lea    0x8(%rsp),%r12
lea    0xca9(%rip),%r14
lea    0xca9(%rip),%rbx
jmp    1400 <main+0x1c0>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10c0 <strcmp@plt>
test   %rax,%rax
je     144a <main+0x20a>
mov    0x0(%r13),%edx
mov    %rbp,%rdi
mov    $0x400,%esi
call   10b0 <fgets@plt>
mov    %rbp,%rdi
call   10f0 <strtrim@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r15d,%edi
mov    %rbp,%rsi
xor    %ecx,%ecx
mov    %r12,%r8
mov    $0x18,%r9d
call   1090 <sendto@plt>
test   %rax,%rax
jns    13f0 <main+0x1b0>
mov    %r14,%rdi
call   1110 <perror@plt>
jmp    13f0 <main+0x1b0>
xor    %edi,%edi
call   1140 <wait@plt>
mov    %r15d,%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i8*, i32 }
%struct.sockaddr = type { i32 }
@.str = [54 x i8] c"usage: %s [<listening-port>] <dest-addr> <dest-port>\0A\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [14 x i8] c"socket failed\00"
@SOL_SOCKET = global i32 0
@SO_BROADCAST = global i32 0
@.str.2 = [21 x i8] c"set broadcast failed\00"
@AF_INET = global i32 0
@.str.3 = [10 x i8] c"128.1.1.1\00"
@.str.4 = [22 x i8] c"inet_aton failed (%s)\00"
@.str.5 = [12 x i8] c"bind failed\00"
@stdin = global i32 0
@.str.6 = [7 x i8] c"sendto\00"
@.str.7 = [4 x i8] c"bye\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 [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %6
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 4
br i1 %15, label %16, label %21
16: ; preds = %13, %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* %19)
store i32 0, i32* %3
br label %123
21: ; preds = %13
%22 = load i32, i32* %4
%23 = icmp eq i32 %22, 4
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = call i32 @atoi(i8* %27)
store i32 %28, i32* %8
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i32 1
store i8** %30, i8*** %5
br label %32
31: ; preds = %21
store i32 9999, i32* %8
br label %32
32: ; preds = %31, %24
%33 = load i32, i32* @PF_INET
%34 = load i32, i32* @SOCK_DGRAM
%35 = call i32 @socket(i32 %33, i32 %34, i32 0)
store i32 %35, i32* %7
%36 = load i32, i32* %7
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %32
%39 = call i32 (i8*, ...) @panic(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %40
40: ; preds = %38, %32
%41 = load i32, i32* %7
%42 = load i32, i32* @SOL_SOCKET
%43 = load i32, i32* @SO_BROADCAST
%44 = call i64 @setsockopt(i32 %41, i32 %42, i32 %43, i32* %6, i32 4)
%45 = icmp ne i64 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %40
%47 = call i32 (i8*, ...) @panic(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %48
48: ; preds = %46, %40
%49 = call i32 @bzero(%struct.sockaddr_in* %9, i32 24)
%50 = load i32, i32* @AF_INET
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %50, i32* %51
%52 = load i32, i32* %8
%53 = call i8* @htons(i32 %52)
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i8* %53, i8** %54
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%56 = call i64 @inet_aton(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32* %55)
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %48
%59 = load i8**, i8*** %5
%60 = getelementptr inbounds i8*, i8** %59, i64 1
%61 = load i8*, i8** %60
%62 = call i32 (i8*, ...) @panic(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %61)
br label %63
63: ; preds = %58, %48
%64 = load i32, i32* %7
%65 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%66 = call i64 @bind(i32 %64, %struct.sockaddr* %65, i32 24)
%67 = icmp ne i64 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %63
%69 = call i32 (i8*, ...) @panic(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %70
70: ; preds = %68, %63
%71 = load i8**, i8*** %5
%72 = getelementptr inbounds i8*, i8** %71, i64 2
%73 = load i8*, i8** %72
%74 = call i32 @atoi(i8* %73)
%75 = call i8* @htons(i32 %74)
%76 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i8* %75, i8** %76
%77 = load i8**, i8*** %5
%78 = getelementptr inbounds i8*, i8** %77, i64 1
%79 = load i8*, i8** %78
%80 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%81 = call i64 @inet_aton(i8* %79, i32* %80)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %88
83: ; preds = %70
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 1
%86 = load i8*, i8** %85
%87 = call i32 (i8*, ...) @panic(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %86)
br label %88
88: ; preds = %83, %70
%89 = call i64 (...) @fork()
%90 = icmp ne i64 %89, 0
br i1 %90, label %91, label %94
91: ; preds = %88
%92 = load i32, i32* %7
%93 = call i32 @Receiver(i32 %92)
br label %97
94: ; preds = %88
%95 = load i32, i32* %7
%96 = call i32 @shutdown(i32 %95, i32 0)
br label %97
97: ; preds = %94, %91
br label %98
98: ; preds = %115, %97
%99 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%100 = load i32, i32* @stdin
%101 = call i32 @fgets(i8* %99, i32 1024, i32 %100)
%102 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%103 = call i32 @strtrim(i8* %102)
%104 = load i32, i32* %7
%105 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%106 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%107 = call i64 @strlen(i8* %106)
%108 = add nsw i64 %107, 1
%109 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%110 = call i64 @sendto(i32 %104, i8* %105, i64 %108, i32 0, %struct.sockaddr* %109, i32 24)
%111 = icmp slt i64 %110, 0
br i1 %111, label %112, label %114
112: ; preds = %98
%113 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %114
114: ; preds = %112, %98
br label %115
115: ; preds = %114
%116 = getelementptr inbounds [1024 x i8], [1024 x i8]* %10, i64 0, i64 0
%117 = call i64 @strcmp(i8* %116, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%118 = icmp ne i64 %117, 0
br i1 %118, label %98, label %119
119: ; preds = %115
%120 = call i32 @wait(i32 0)
%121 = load i32, i32* %7
%122 = call i32 @close(i32 %121)
store i32 0, i32* %3
br label %123
123: ; preds = %119, %16
%124 = load i32, i32* %3
ret i32 %124
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i8*, i32 }
%struct.sockaddr = type { i32 }
@.str = [54 x i8] c"usage: %s [<listening-port>] <dest-addr> <dest-port>\0A\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [14 x i8] c"socket failed\00"
@SOL_SOCKET = global i32 0
@SO_BROADCAST = global i32 0
@.str.2 = [21 x i8] c"set broadcast failed\00"
@AF_INET = global i32 0
@.str.3 = [10 x i8] c"128.1.1.1\00"
@.str.4 = [22 x i8] c"inet_aton failed (%s)\00"
@.str.5 = [12 x i8] c"bind failed\00"
@stdin = global i32 0
@.str.6 = [7 x i8] c"sendto\00"
@.str.7 = [4 x i8] c"bye\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca [1024 x i8]
%6 = bitcast i32* %3 to i8*
store i32 1, i32* %3
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %5, i64 0, i64 0
%9 = add i32 %0, -5
%10 = icmp ult i32 %9, -2
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8*, i8** %1
%13 = tail call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i8* %12)
br label %91
14: ; preds = %2
%15 = icmp eq i32 %0, 4
br i1 %15, label %16, label %20
16: ; preds = %14
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = tail call i32 @atoi(i8* %18)
br label %20
20: ; preds = %14, %16
%21 = phi i8** [ %17, %16 ], [ %1, %14 ]
%22 = phi i32 [ %19, %16 ], [ 9999, %14 ]
%23 = load i32, i32* @PF_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 = %20
%28 = tail call i32 (i8*, ...) @panic(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %20
%30 = load i32, i32* @SOL_SOCKET
%31 = load i32, i32* @SO_BROADCAST
%32 = call i64 @setsockopt(i32 %25, i32 %30, i32 %31, i32* %3, i32 4)
%33 = icmp eq i64 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %29
%35 = call i32 (i8*, ...) @panic(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
%37 = call i32 @bzero(%struct.sockaddr_in* %4, i32 24)
%38 = load i32, i32* @AF_INET
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %38, i32* %39
%40 = call i8* @htons(i32 %22)
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i8* %40, i8** %41
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%43 = call i64 @inet_aton(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32* %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %49
45: ; preds = %36
%46 = getelementptr inbounds i8*, i8** %21, i64 1
%47 = load i8*, i8** %46
%48 = call i32 (i8*, ...) @panic(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %47)
br label %49
49: ; preds = %45, %36
%50 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%51 = call i64 @bind(i32 %25, %struct.sockaddr* %50, i32 24)
%52 = icmp eq i64 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %49
%54 = call i32 (i8*, ...) @panic(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %55
55: ; preds = %53, %49
%56 = getelementptr inbounds i8*, i8** %21, i64 2
%57 = load i8*, i8** %56
%58 = call i32 @atoi(i8* %57)
%59 = call i8* @htons(i32 %58)
store i8* %59, i8** %41
%60 = getelementptr inbounds i8*, i8** %21, i64 1
%61 = load i8*, i8** %60
%62 = call i64 @inet_aton(i8* %61, i32* %42)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %67
64: ; preds = %55
%65 = load i8*, i8** %60
%66 = call i32 (i8*, ...) @panic(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i8* %65)
br label %67
67: ; preds = %64, %55
%68 = call i64 (...) @fork()
%69 = icmp eq i64 %68, 0
br i1 %69, label %72, label %70
70: ; preds = %67
%71 = call i32 @Receiver(i32 %25)
br label %74
72: ; preds = %67
%73 = call i32 @shutdown(i32 %25, i32 0)
br label %74
74: ; preds = %72, %70
br label %75
75: ; preds = %74, %85
%76 = load i32, i32* @stdin
%77 = call i32 @fgets(i8* %8, i32 1024, i32 %76)
%78 = call i32 @strtrim(i8* %8)
%79 = call i64 @strlen(i8* %8)
%80 = add nsw i64 %79, 1
%81 = call i64 @sendto(i32 %25, i8* %8, i64 %80, i32 0, %struct.sockaddr* %50, i32 24)
%82 = icmp slt i64 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %75
%84 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
br label %85
85: ; preds = %75, %83
%86 = call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %75
88: ; preds = %85
%89 = call i32 @wait(i32 0)
%90 = call i32 @close(i32 %25)
br label %91
91: ; preds = %88, %11
ret i32 0
}