#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__ {
  scalar_t__ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ member_0;
};
struct sockaddr {
  int dummy;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ remote_address;
typedef int /*<<< orphan*/ destination_socket_address;
typedef int /*<<< orphan*/ broadcastEnable;

/* Variables and functions */
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_BROADCAST;
int /*<<< orphan*/ close(int);
int create_bounded_socket(struct sockaddr_in);
int /*<<< orphan*/ fill_socketaddr_in(struct sockaddr_in *, int, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
scalar_t__ htonl(int);
int inet_network(char *);
char *inet_ntoa(TYPE_1__);
char *malloc(int);
int ntohl(scalar_t__);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
scalar_t__ sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int init_socket;
  struct sockaddr_in init_socket_address = {0},
                     forward_reply_socket_address = {0},
                     destination_socket_address = {0};
  struct sockaddr_in remote_address;
  socklen_t remote_address_length = sizeof(remote_address);
  char *receive_buffer = malloc(1E3 * sizeof(char));
  if (argc != 4) {
    fprintf(stderr,
            "Call with 3 arguments:\n%s external-interface-ip-address "
            "internal-interface-ip-address sonos-box-ip-address",
            argv[0]);
  }
  char *outside_nat_ip_address = argv[1];
  char *inside_nat_ip_address = argv[2];
  char *sonos_box_ip_address = argv[3];
  fill_socketaddr_in(&init_socket_address, 6969, "0.0.0.0");
  init_socket = create_bounded_socket(init_socket_address);
  printf("waiting for connection\n");
  while (1) {
    int nr_bytes_received;
    nr_bytes_received =
        recvfrom(init_socket, receive_buffer, 1E3, 0,
                 (struct sockaddr *)&remote_address, &remote_address_length);
    if (remote_address.sin_addr.s_addr ==
            htonl(inet_network(outside_nat_ip_address)) ||
        remote_address.sin_addr.s_addr ==
            htonl(inet_network(inside_nat_ip_address))) {
      continue;
    }
    long r_addr = ntohl(remote_address.sin_addr.s_addr);
    fill_socketaddr_in(&forward_reply_socket_address, 0, inside_nat_ip_address);
    if ((r_addr & 0xFFFFFF00) ==
        (ntohl(forward_reply_socket_address.sin_addr.s_addr) & 0xFFFFFF00)) {
      fill_socketaddr_in(&forward_reply_socket_address, 0,
                         outside_nat_ip_address);
      fill_socketaddr_in(&destination_socket_address, 6969,
                         outside_nat_ip_address);
    } else {
      fill_socketaddr_in(&destination_socket_address, 6969,
                         inside_nat_ip_address);
    }
    destination_socket_address.sin_addr.s_addr = htonl(
        ntohl(destination_socket_address.sin_addr.s_addr) & 0xFFFFFF00 | 0xFF);
    printf("Message %s --> ", inet_ntoa(remote_address.sin_addr));
    printf("%s", inet_ntoa(forward_reply_socket_address.sin_addr));
    printf("(%s)\n", inet_ntoa(destination_socket_address.sin_addr));
    int passthrough_socket =
        create_bounded_socket(forward_reply_socket_address);
    int broadcastEnable = 1;
    if (setsockopt(passthrough_socket, SOL_SOCKET, SO_BROADCAST,
                   &broadcastEnable, sizeof(broadcastEnable)) < 0) {
      perror("setopt failed");
    }
    if (sendto(passthrough_socket, receive_buffer, nr_bytes_received, 0,
               (struct sockaddr *)&destination_socket_address,
               sizeof(destination_socket_address)) <= 0) {
      perror("send failed");
    }
    close(passthrough_socket);
  }
}


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)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <memset@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <memset@plt>
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <memset@plt>
movl   $0x10,-0x5c(%rbp)
mov    $0x3e8,%edi
call   10d0 <malloc@plt>
mov    %rax,-0x68(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1274 <main+0x84>
mov    0x2d71(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd91(%rip),%rsi
call   10c0 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x70(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x80(%rbp)
lea    -0x28(%rbp),%rdi
mov    $0x1b39,%esi
lea    0xdc3(%rip),%rdx
call   1100 <fill_socketaddr_in@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1090 <create_bounded_socket@plt>
mov    %eax,-0x14(%rbp)
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%edi
mov    -0x68(%rbp),%rsi
lea    -0x58(%rbp),%r8
mov    $0x3e8,%edx
xor    %ecx,%ecx
lea    -0x5c(%rbp),%r9
call   10e0 <recvfrom@plt>
mov    %eax,-0x84(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x70(%rbp),%rdi
call   1040 <inet_network@plt>
mov    %eax,%edi
call   1070 <htonl@plt>
mov    %rax,%rcx
mov    -0xa0(%rbp),%rax
cmp    %rcx,%rax
je     1347 <main+0x157>
mov    -0x58(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x78(%rbp),%rdi
call   1040 <inet_network@plt>
mov    %eax,%edi
call   1070 <htonl@plt>
mov    %rax,%rcx
mov    -0xa8(%rbp),%rax
cmp    %rcx,%rax
jne    134c <main+0x15c>
jmp    12ca <main+0xda>
mov    -0x58(%rbp),%rdi
call   1110 <ntohl@plt>
cltq
mov    %rax,-0x90(%rbp)
mov    -0x78(%rbp),%rdx
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1100 <fill_socketaddr_in@plt>
movabs $0xffffff00,%rax
and    -0x90(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x38(%rbp),%rdi
call   1110 <ntohl@plt>
mov    %eax,%ecx
mov    -0xb0(%rbp),%rax
and    $0xffffff00,%ecx
mov    %ecx,%ecx
cmp    %rcx,%rax
jne    13ce <main+0x1de>
mov    -0x70(%rbp),%rdx
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
call   1100 <fill_socketaddr_in@plt>
mov    -0x70(%rbp),%rdx
lea    -0x48(%rbp),%rdi
mov    $0x1b39,%esi
call   1100 <fill_socketaddr_in@plt>
jmp    13e0 <main+0x1f0>
mov    -0x78(%rbp),%rdx
lea    -0x48(%rbp),%rdi
mov    $0x1b39,%esi
call   1100 <fill_socketaddr_in@plt>
mov    -0x48(%rbp),%rdi
call   1110 <ntohl@plt>
mov    %eax,%edi
and    $0xffffff00,%edi
or     $0xff,%edi
call   1070 <htonl@plt>
mov    %rax,-0x48(%rbp)
mov    -0x58(%rbp),%rdi
call   1050 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xc78(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
call   1050 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xc6e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1050 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xc57(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%esi
call   1090 <create_bounded_socket@plt>
mov    %eax,-0x94(%rbp)
movl   $0x1,-0x98(%rbp)
mov    -0x94(%rbp),%edi
mov    0x2b71(%rip),%rax
mov    (%rax),%esi
mov    0x2b60(%rip),%rax
mov    (%rax),%edx
lea    -0x98(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    14aa <main+0x2ba>
lea    0xbff(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x94(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    -0x84(%rbp),%edx
lea    -0x48(%rbp),%r8
xor    %ecx,%ecx
mov    $0x10,%r9d
call   10a0 <sendto@plt>
cmp    $0x0,%rax
jg     14e1 <main+0x2f1>
lea    0xbd6(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x94(%rbp),%edi
call   10b0 <close@plt>
jmp    12ca <main+0xda>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%rbp
mov    %edi,%ebx
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movl   $0x10,0xc(%rsp)
mov    $0x3e8,%edi
call   10d0 <malloc@plt>
mov    %rax,%r14
cmp    $0x4,%ebx
je     1248 <main+0x58>
mov    0x2d9a(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%rdx
lea    0xdbd(%rip),%rsi
call   10c0 <fprintf@plt>
mov    0x8(%rbp),%r15
mov    0x10(%rbp),%r13
lea    0xe14(%rip),%rdx
lea    0x40(%rsp),%rdi
mov    $0x1b39,%esi
call   1100 <fill_socketaddr_in@plt>
mov    0x40(%rsp),%rdi
mov    0x48(%rsp),%esi
call   1090 <create_bounded_socket@plt>
mov    %eax,%ebx
lea    0xe29(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,0x4(%rsp)
jmp    129f <main+0xaf>
nopl   0x0(%rax,%rax,1)
mov    %r13d,%edi
call   10b0 <close@plt>
mov    %rbp,%r13
mov    0x4(%rsp),%ebx
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x3e8,%edx
xor    %ecx,%ecx
lea    0x30(%rsp),%r8
lea    0xc(%rsp),%r9
call   10e0 <recvfrom@plt>
mov    %eax,%r12d
mov    0x30(%rsp),%rbp
mov    %r15,%rdi
call   1050 <inet_network@plt>
mov    %eax,%edi
call   1080 <htonl@plt>
cmp    %rax,%rbp
je     129f <main+0xaf>
mov    0x30(%rsp),%rbp
mov    %r13,%rdi
call   1050 <inet_network@plt>
mov    %eax,%edi
call   1080 <htonl@plt>
cmp    %rax,%rbp
je     129f <main+0xaf>
mov    0x30(%rsp),%rdi
call   1110 <ntohl@plt>
mov    %eax,%ebp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    %r13,%rdx
call   1100 <fill_socketaddr_in@plt>
mov    0x10(%rsp),%rdi
call   1110 <ntohl@plt>
xor    %ebp,%eax
mov    %r13,%rbp
cmp    $0xff,%eax
ja     1332 <main+0x142>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1100 <fill_socketaddr_in@plt>
mov    %r15,%r13
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1b39,%esi
mov    %r13,%rdx
call   1100 <fill_socketaddr_in@plt>
mov    0x20(%rsp),%rdi
call   1110 <ntohl@plt>
or     $0xff,%eax
mov    %eax,%edi
call   1080 <htonl@plt>
mov    %rax,0x20(%rsp)
mov    0x30(%rsp),%rdi
call   1060 <inet_ntoa@plt>
lea    0xd00(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%rdi
call   1060 <inet_ntoa@plt>
lea    0xcf5(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x20(%rsp),%rdi
call   1060 <inet_ntoa@plt>
lea    0xcdd(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x10(%rsp),%rdi
mov    0x18(%rsp),%esi
call   1090 <create_bounded_socket@plt>
mov    %eax,%r13d
movl   $0x1,0x8(%rsp)
mov    0x2c15(%rip),%rax
mov    (%rax),%esi
mov    0x2c04(%rip),%rax
mov    (%rax),%edx
mov    %r13d,%edi
lea    0x8(%rsp),%rcx
mov    $0x4,%r8d
call   1040 <setsockopt@plt>
test   %rax,%rax
js     1429 <main+0x239>
mov    %r13d,%edi
mov    %r14,%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    $0x10,%r9d
call   10a0 <sendto@plt>
test   %rax,%rax
jg     1290 <main+0xa0>
lea    0xc7b(%rip),%rdi
call   10f0 <perror@plt>
jmp    1290 <main+0xa0>
lea    0xc5c(%rip),%rdi
call   10f0 <perror@plt>
jmp    13f6 <main+0x206>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [107 x i8] c"Call with 3 arguments:\0A%s external-interface-ip-address internal-interface-ip-address sonos-box-ip-address\00"
@.str.1 = [8 x i8] c"0.0.0.0\00"
@.str.2 = [24 x i8] c"waiting for connection\0A\00"
@.str.3 = [16 x i8] c"Message %s --> \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [6 x i8] c"(%s)\0A\00"
@SOL_SOCKET = global i32 0
@SO_BROADCAST = global i32 0
@.str.6 = [14 x i8] c"setopt failed\00"
@.str.7 = [12 x i8] c"send failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.sockaddr_in
%8 = alloca %struct.sockaddr_in
%9 = alloca %struct.sockaddr_in
%10 = alloca %struct.sockaddr_in
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i32
%17 = alloca i64
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = bitcast %struct.sockaddr_in* %7 to i8*
%21 = bitcast %struct.sockaddr_in* %8 to i8*
%22 = bitcast %struct.sockaddr_in* %9 to i8*
store i32 16, i32* %11
%23 = call i8* @malloc(i32 1000)
store i8* %23, i8** %12
%24 = load i32, i32* %4
%25 = icmp ne i32 %24, 4
br i1 %25, label %26, label %32
26: ; preds = %2
%27 = load i32, i32* @stderr
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 0
%30 = load i8*, i8** %29
%31 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str, i64 0, i64 0), i8* %30)
br label %32
32: ; preds = %26, %2
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 1
%35 = load i8*, i8** %34
store i8* %35, i8** %13
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 2
%38 = load i8*, i8** %37
store i8* %38, i8** %14
%39 = load i8**, i8*** %5
%40 = getelementptr inbounds i8*, i8** %39, i64 3
%41 = load i8*, i8** %40
store i8* %41, i8** %15
%42 = call i32 @fill_socketaddr_in(%struct.sockaddr_in* %7, i32 6969, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%43 = bitcast %struct.sockaddr_in* %7 to { i64, i32 }*
%44 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %43, i32 0, i32 0
%45 = load i64, i64* %44
%46 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %43, i32 0, i32 1
%47 = load i32, i32* %46
%48 = call i32 @create_bounded_socket(i64 %45, i32 %47)
store i32 %48, i32* %6
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %50
50: ; preds = %32, %70, %143
%51 = load i32, i32* %6
%52 = load i8*, i8** %12
%53 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%54 = call i32 @recvfrom(i32 %51, i8* %52, i32 1000, i32 0, %struct.sockaddr* %53, i32* %11)
store i32 %54, i32* %16
%55 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i32 0, i32 0
%57 = load i64, i64* %56
%58 = load i8*, i8** %13
%59 = call i32 @inet_network(i8* %58)
%60 = call i64 @htonl(i32 %59)
%61 = icmp eq i64 %57, %60
br i1 %61, label %70, label %62
62: ; preds = %50
%63 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%64 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %63, i32 0, i32 0
%65 = load i64, i64* %64
%66 = load i8*, i8** %14
%67 = call i32 @inet_network(i8* %66)
%68 = call i64 @htonl(i32 %67)
%69 = icmp eq i64 %65, %68
br i1 %69, label %70, label %71
70: ; preds = %62, %50
br label %50
71: ; preds = %62
%72 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%73 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %72, i32 0, i32 0
%74 = load i64, i64* %73
%75 = call i32 @ntohl(i64 %74)
%76 = sext i32 %75 to i64
store i64 %76, i64* %17
%77 = load i8*, i8** %14
%78 = call i32 @fill_socketaddr_in(%struct.sockaddr_in* %8, i32 0, i8* %77)
%79 = load i64, i64* %17
%80 = and i64 %79, 4294967040
%81 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%82 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %81, i32 0, i32 0
%83 = load i64, i64* %82
%84 = call i32 @ntohl(i64 %83)
%85 = and i32 %84, -256
%86 = zext i32 %85 to i64
%87 = icmp eq i64 %80, %86
br i1 %87, label %88, label %93
88: ; preds = %71
%89 = load i8*, i8** %13
%90 = call i32 @fill_socketaddr_in(%struct.sockaddr_in* %8, i32 0, i8* %89)
%91 = load i8*, i8** %13
%92 = call i32 @fill_socketaddr_in(%struct.sockaddr_in* %9, i32 6969, i8* %91)
br label %96
93: ; preds = %71
%94 = load i8*, i8** %14
%95 = call i32 @fill_socketaddr_in(%struct.sockaddr_in* %9, i32 6969, i8* %94)
br label %96
96: ; preds = %93, %88
%97 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%98 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %97, i32 0, i32 0
%99 = load i64, i64* %98
%100 = call i32 @ntohl(i64 %99)
%101 = and i32 %100, -256
%102 = or i32 %101, 255
%103 = call i64 @htonl(i32 %102)
%104 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%105 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %104, i32 0, i32 0
store i64 %103, i64* %105
%106 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%107 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %106, i32 0, i32 0
%108 = load i64, i64* %107
%109 = call i8* @inet_ntoa(i64 %108)
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %109)
%111 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%112 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %111, i32 0, i32 0
%113 = load i64, i64* %112
%114 = call i8* @inet_ntoa(i64 %113)
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %114)
%116 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%117 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %116, i32 0, i32 0
%118 = load i64, i64* %117
%119 = call i8* @inet_ntoa(i64 %118)
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %119)
%121 = bitcast %struct.sockaddr_in* %8 to { i64, i32 }*
%122 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %121, i32 0, i32 0
%123 = load i64, i64* %122
%124 = getelementptr inbounds { i64, i32 }, { i64, i32 }* %121, i32 0, i32 1
%125 = load i32, i32* %124
%126 = call i32 @create_bounded_socket(i64 %123, i32 %125)
store i32 %126, i32* %18
store i32 1, i32* %19
%127 = load i32, i32* %18
%128 = load i32, i32* @SOL_SOCKET
%129 = load i32, i32* @SO_BROADCAST
%130 = call i64 @setsockopt(i32 %127, i32 %128, i32 %129, i32* %19, i32 4)
%131 = icmp slt i64 %130, 0
br i1 %131, label %132, label %134
132: ; preds = %96
%133 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %134
134: ; preds = %132, %96
%135 = load i32, i32* %18
%136 = load i8*, i8** %12
%137 = load i32, i32* %16
%138 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%139 = call i64 @sendto(i32 %135, i8* %136, i32 %137, i32 0, %struct.sockaddr* %138, i32 16)
%140 = icmp sle i64 %139, 0
br i1 %140, label %141, label %143
141: ; preds = %134
%142 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %143
143: ; preds = %141, %134
%144 = load i32, i32* %18
%145 = call i32 @close(i32 %144)
br label %50
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [107 x i8] c"Call with 3 arguments:\0A%s external-interface-ip-address internal-interface-ip-address sonos-box-ip-address\00"
@.str.1 = [8 x i8] c"0.0.0.0\00"
@.str.3 = [16 x i8] c"Message %s --> \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [6 x i8] c"(%s)\0A\00"
@SOL_SOCKET = global i32 0
@SO_BROADCAST = global i32 0
@.str.6 = [14 x i8] c"setopt failed\00"
@.str.7 = [12 x i8] c"send failed\00"
@str = [23 x i8] c"waiting for connection\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.sockaddr_in
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = alloca i32
%9 = bitcast %struct.sockaddr_in* %3 to i8*
%10 = bitcast %struct.sockaddr_in* %4 to i8*
%11 = bitcast %struct.sockaddr_in* %5 to i8*
%12 = bitcast %struct.sockaddr_in* %6 to i8*
%13 = bitcast i32* %7 to i8*
store i32 16, i32* %7
%14 = tail call dereferenceable_or_null(1000) i8* @malloc(i32 1000)
%15 = icmp eq i32 %0, 4
br i1 %15, label %20, label %16
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = tail call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([107 x i8], [107 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16, %2
%21 = getelementptr inbounds i8*, i8** %1, i64 1
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8*, i8** %1, i64 2
%24 = load i8*, i8** %23
%25 = call i32 @fill_socketaddr_in(%struct.sockaddr_in* %3, i32 6969, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0, i32 0
%27 = load i64, i64* %26
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%29 = load i32, i32* %28
%30 = call i32 @create_bounded_socket(i64 %27, i32 %29)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%32 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0, i32 0
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
%37 = bitcast i32* %8 to i8*
%38 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
br label %39
39: ; preds = %45, %20
%40 = call i32 @recvfrom(i32 %30, i8* %14, i32 1000, i32 0, %struct.sockaddr* %32, i32* %7)
%41 = load i64, i64* %33
%42 = call i32 @inet_network(i8* %22)
%43 = call i64 @htonl(i32 %42)
%44 = icmp eq i64 %41, %43
br i1 %44, label %45, label %46
45: ; preds = %39, %46, %91
br label %39
46: ; preds = %39
%47 = load i64, i64* %33
%48 = call i32 @inet_network(i8* %24)
%49 = call i64 @htonl(i32 %48)
%50 = icmp eq i64 %47, %49
br i1 %50, label %45, label %51
51: ; preds = %46
%52 = load i64, i64* %33
%53 = call i32 @ntohl(i64 %52)
%54 = call i32 @fill_socketaddr_in(%struct.sockaddr_in* %4, i32 0, i8* %24)
%55 = load i64, i64* %34
%56 = call i32 @ntohl(i64 %55)
%57 = xor i32 %56, %53
%58 = icmp ult i32 %57, 256
br i1 %58, label %59, label %61
59: ; preds = %51
%60 = call i32 @fill_socketaddr_in(%struct.sockaddr_in* %4, i32 0, i8* %22)
br label %61
61: ; preds = %51, %59
%62 = phi i8* [ %22, %59 ], [ %24, %51 ]
%63 = call i32 @fill_socketaddr_in(%struct.sockaddr_in* %5, i32 6969, i8* %62)
%64 = load i64, i64* %35
%65 = call i32 @ntohl(i64 %64)
%66 = or i32 %65, 255
%67 = call i64 @htonl(i32 %66)
store i64 %67, i64* %35
%68 = load i64, i64* %33
%69 = call i8* @inet_ntoa(i64 %68)
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i8* %69)
%71 = load i64, i64* %34
%72 = call i8* @inet_ntoa(i64 %71)
%73 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %72)
%74 = load i64, i64* %35
%75 = call i8* @inet_ntoa(i64 %74)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %75)
%77 = load i64, i64* %34
%78 = load i32, i32* %36
%79 = call i32 @create_bounded_socket(i64 %77, i32 %78)
store i32 1, i32* %8
%80 = load i32, i32* @SOL_SOCKET
%81 = load i32, i32* @SO_BROADCAST
%82 = call i64 @setsockopt(i32 %79, i32 %80, i32 %81, i32* %8, i32 4)
%83 = icmp slt i64 %82, 0
br i1 %83, label %84, label %86
84: ; preds = %61
%85 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
br label %86
86: ; preds = %84, %61
%87 = call i64 @sendto(i32 %79, i8* %14, i32 %40, i32 0, %struct.sockaddr* %38, i32 16)
%88 = icmp slt i64 %87, 1
br i1 %88, label %89, label %91
89: ; preds = %86
%90 = call i32 @perror(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.7, i64 0, i64 0))
br label %91
91: ; preds = %89, %86
%92 = call i32 @close(i32 %79)
br label %45
}