#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_6__ TYPE_3__;
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  void *s_addr;
};
struct sockaddr_in {
  TYPE_3__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct TYPE_5__ {
  void *s_addr;
};
struct TYPE_4__ {
  int /*<<< orphan*/ s_addr;
};
struct ip_mreq {
  TYPE_2__ imr_interface;
  TYPE_1__ imr_multiaddr;
};
typedef int /*<<< orphan*/ optVal;
typedef int /*<<< orphan*/ mcastReq;
typedef int /*<<< orphan*/ mcastAddr;
typedef int /*<<< orphan*/ fromAddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IPPROTO_UDP;
int /*<<< orphan*/ IP_ADD_MEMBERSHIP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOL_SOCKET;
int /*<<< orphan*/ SO_REUSEADDR;
unsigned int atoi(char *);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
void *htonl(int /*<<< orphan*/);
int /*<<< orphan*/ htons(unsigned int);
int /*<<< orphan*/ inet_addr(char *);
char *inet_ntoa(TYPE_3__);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, char *, char *);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *,
             unsigned int *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, void *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char *mcastIP;
  unsigned int mcastPort;
  int sock;
  int optVal;
  struct sockaddr_in mcastAddr;
  struct ip_mreq mcastReq;
  int msgCount;
  struct sockaddr_in fromAddr;
  unsigned int fromAddrLen;
  char msgBuffer[(255) + 1];
  int recvMsgLen;
  if (argc != 3) {
    fprintf(stderr, "Usage: %s <Multicast IP Address> <Multicast Port>\n",
            argv[0]);
    exit(1);
  }
  mcastIP = argv[1];
  mcastPort = atoi(argv[2]);
  sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
  if (sock < 0) {
    fprintf(stderr, "socket() failed\n");
    exit(1);
  }
  memset(&mcastAddr, 0, sizeof(mcastAddr));
  mcastAddr.sin_family = AF_INET;
  mcastAddr.sin_addr.s_addr = htonl(INADDR_ANY);
  mcastAddr.sin_port = htons(mcastPort);
  optVal = 1;
  if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&optVal,
                 sizeof(optVal)) < 0) {
    fprintf(stderr, "setsockopt() failed\n");
    exit(1);
  }
  if (bind(sock, (struct sockaddr *)&mcastAddr, sizeof(mcastAddr)) < 0) {
    fprintf(stderr, "bind() failed\n");
    exit(1);
  }
  mcastReq.imr_multiaddr.s_addr = inet_addr(mcastIP);
  mcastReq.imr_interface.s_addr = htonl(INADDR_ANY);
  if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, (void *)&mcastReq,
                 sizeof(mcastReq)) < 0) {
    fprintf(stderr, "setsockopt() failed\n");
    exit(1);
  }
  for (msgCount = 0; msgCount < 4; msgCount++) {
    fromAddrLen = sizeof(fromAddr);
    recvMsgLen = recvfrom(sock, msgBuffer, (255), 0,
                          (struct sockaddr *)&fromAddr, &fromAddrLen);
    if (recvMsgLen < 0) {
      fprintf(stderr, "recvfrom() failed\n");
      exit(1);
    }
    msgBuffer[recvMsgLen] = '\0';
    printf("Received: %s from %s\n", msgBuffer, inet_ntoa(fromAddr.sin_addr));
  }
  close(sock);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     122b <main+0x4b>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xde6(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10e0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2d5a(%rip),%rax
mov    (%rax),%edi
mov    0x2d69(%rip),%rax
mov    (%rax),%esi
mov    0x2d30(%rip),%rax
mov    (%rax),%edx
call   1100 <socket@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    1295 <main+0xb5>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
lea    0xdaf(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <memset@plt>
mov    0x2d2c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2d10(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
call   1050 <htons@plt>
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x20(%rbp),%edi
mov    0x2d09(%rip),%rax
mov    (%rax),%esi
mov    0x2cb8(%rip),%rax
mov    (%rax),%edx
lea    -0x24(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1324 <main+0x144>
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
lea    0xd31(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x20(%rbp),%edi
lea    -0x38(%rbp),%rsi
mov    $0x10,%edx
call   10d0 <bind@plt>
cmp    $0x0,%rax
jge    1360 <main+0x180>
mov    0x2c6a(%rip),%rax
mov    (%rax),%edi
lea    0xd0a(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,-0x40(%rbp)
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%edi
mov    0x2c48(%rip),%rax
mov    (%rax),%esi
mov    0x2c4f(%rip),%rax
mov    (%rax),%edx
lea    -0x48(%rbp),%rcx
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    13cd <main+0x1ed>
mov    0x2bfd(%rip),%rax
mov    (%rax),%edi
lea    0xc88(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movl   $0x0,-0x4c(%rbp)
cmpl   $0x4,-0x4c(%rbp)
jge    1481 <main+0x2a1>
movl   $0x10,-0x64(%rbp)
mov    -0x20(%rbp),%edi
lea    -0x170(%rbp),%rsi
lea    -0x60(%rbp),%r8
mov    $0xff,%edx
xor    %ecx,%ecx
lea    -0x64(%rbp),%r9
call   10c0 <recvfrom@plt>
mov    %eax,-0x174(%rbp)
cmpl   $0x0,-0x174(%rbp)
jge    1437 <main+0x257>
mov    0x2b93(%rip),%rax
mov    (%rax),%edi
lea    0xc42(%rip),%rsi
mov    $0x0,%al
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
movslq -0x174(%rbp),%rax
movb   $0x0,-0x170(%rbp,%rax,1)
lea    -0x170(%rbp),%rax
mov    %rax,-0x180(%rbp)
mov    -0x60(%rbp),%rdi
call   1040 <inet_ntoa@plt>
mov    -0x180(%rbp),%rsi
mov    %rax,%rdx
lea    0xc0d(%rip),%rdi
call   1060 <printf@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    13d4 <main+0x1f4>
mov    -0x20(%rbp),%edi
call   1090 <close@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x148,%rsp
cmp    $0x3,%edi
jne    123a <main+0x5a>
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%rdi
call   10e0 <atoi@plt>
mov    %eax,%ebp
mov    0x2da0(%rip),%rax
mov    (%rax),%edi
mov    0x2daf(%rip),%rax
mov    (%rax),%esi
mov    0x2d76(%rip),%rax
mov    (%rax),%edx
call   1100 <socket@plt>
test   %eax,%eax
jns    125e <main+0x7e>
mov    0x2d84(%rip),%rax
mov    (%rax),%edi
lea    0xdfe(%rip),%rsi
jmp    1482 <main+0x2a2>
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xdb3(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    %eax,%ebx
lea    0x20(%rsp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1080 <memset@plt>
mov    0x2d60(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x2c(%rsp)
mov    0x2d43(%rip),%r15
mov    (%r15),%edi
call   1070 <htonl@plt>
mov    %rax,0x20(%rsp)
mov    %ebp,%edi
call   1050 <htons@plt>
mov    %eax,0x28(%rsp)
movl   $0x1,0x1c(%rsp)
mov    0x2d3c(%rip),%rax
mov    (%rax),%esi
mov    0x2ceb(%rip),%rax
mov    (%rax),%edx
lea    0x1c(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    12e3 <main+0x103>
mov    0x2cdb(%rip),%rax
mov    (%rax),%edi
lea    0xd66(%rip),%rsi
jmp    1482 <main+0x2a2>
lea    0x20(%rsp),%rsi
mov    %ebx,%edi
mov    $0x10,%edx
call   10d0 <bind@plt>
test   %rax,%rax
jns    130e <main+0x12e>
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
lea    0xd50(%rip),%rsi
jmp    1482 <main+0x2a2>
mov    %r14,%rdi
call   10a0 <inet_addr@plt>
mov    %eax,0x38(%rsp)
mov    (%r15),%edi
call   1070 <htonl@plt>
mov    %rax,0x30(%rsp)
mov    0x2ca2(%rip),%rax
mov    (%rax),%esi
mov    0x2ca9(%rip),%rax
mov    (%rax),%edx
lea    0x30(%rsp),%rcx
mov    %ebx,%edi
mov    $0x10,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     12ce <main+0xee>
movl   $0x10,0x4(%rsp)
lea    0x40(%rsp),%rsi
lea    0x8(%rsp),%r8
lea    0x4(%rsp),%r9
mov    %ebx,%edi
mov    $0xff,%edx
xor    %ecx,%ecx
call   10c0 <recvfrom@plt>
test   %eax,%eax
js     1472 <main+0x292>
mov    %eax,%eax
movb   $0x0,0x40(%rsp,%rax,1)
mov    0x8(%rsp),%rdi
call   1040 <inet_ntoa@plt>
lea    0xce2(%rip),%rdi
lea    0x40(%rsp),%rbp
mov    %rbp,%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
movl   $0x10,0x4(%rsp)
lea    0x8(%rsp),%r8
lea    0x4(%rsp),%r9
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0xff,%edx
xor    %ecx,%ecx
call   10c0 <recvfrom@plt>
test   %eax,%eax
js     1472 <main+0x292>
mov    %eax,%eax
movb   $0x0,0x40(%rsp,%rax,1)
mov    0x8(%rsp),%rdi
call   1040 <inet_ntoa@plt>
lea    0xc8f(%rip),%rdi
lea    0x40(%rsp),%rbp
mov    %rbp,%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
movl   $0x10,0x4(%rsp)
lea    0x8(%rsp),%r8
lea    0x4(%rsp),%r9
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0xff,%edx
xor    %ecx,%ecx
call   10c0 <recvfrom@plt>
test   %eax,%eax
js     1472 <main+0x292>
mov    %eax,%eax
movb   $0x0,0x40(%rsp,%rax,1)
mov    0x8(%rsp),%rdi
call   1040 <inet_ntoa@plt>
lea    0xc40(%rip),%rdi
lea    0x40(%rsp),%rbp
mov    %rbp,%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
movl   $0x10,0x4(%rsp)
lea    0x8(%rsp),%r8
lea    0x4(%rsp),%r9
mov    %ebx,%edi
mov    %rbp,%rsi
mov    $0xff,%edx
xor    %ecx,%ecx
call   10c0 <recvfrom@plt>
test   %eax,%eax
jns    1493 <main+0x2b3>
mov    0x2b37(%rip),%rax
mov    (%rax),%edi
lea    0xbe6(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    %eax,%eax
movb   $0x0,0x40(%rsp,%rax,1)
mov    0x8(%rsp),%rdi
call   1040 <inet_ntoa@plt>
lea    0xbd0(%rip),%rdi
lea    0x40(%rsp),%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
mov    %ebx,%edi
call   1090 <close@plt>
xor    %edi,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_6__, i32, i32 }
%struct.TYPE_6__ = type { i8* }
%struct.ip_mreq = type { %struct.TYPE_5__, %struct.TYPE_4__ }
%struct.TYPE_5__ = type { i8* }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [51 x i8] c"Usage: %s <Multicast IP Address> <Multicast Port>\0A\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.1 = [17 x i8] c"socket() failed\0A\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [21 x i8] c"setsockopt() failed\0A\00"
@.str.3 = [15 x i8] c"bind() failed\0A\00"
@IPPROTO_IP = global i32 0
@IP_ADD_MEMBERSHIP = global i32 0
@.str.4 = [19 x i8] c"recvfrom() failed\0A\00"
@.str.5 = [22 x i8] c"Received: %s from %s\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.sockaddr_in
%11 = alloca %struct.ip_mreq
%12 = alloca i32
%13 = alloca %struct.sockaddr_in
%14 = alloca i32
%15 = alloca [256 x i8]
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 3
br i1 %18, label %19, label %26
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
store i8* %29, i8** %6
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 2
%32 = load i8*, i8** %31
%33 = call i32 @atoi(i8* %32)
store i32 %33, i32* %7
%34 = load i32, i32* @PF_INET
%35 = load i32, i32* @SOCK_DGRAM
%36 = load i32, i32* @IPPROTO_UDP
%37 = call i32 @socket(i32 %34, i32 %35, i32 %36)
store i32 %37, i32* %8
%38 = load i32, i32* %8
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %26
%41 = load i32, i32* @stderr
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%43 = call i32 @exit(i32 1)
unreachable
44: ; preds = %26
%45 = call i32 @memset(%struct.sockaddr_in* %10, i32 0, i32 16)
%46 = load i32, i32* @AF_INET
%47 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 2
store i32 %46, i32* %47
%48 = load i32, i32* @INADDR_ANY
%49 = call i8* @htonl(i32 %48)
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 0
%51 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %50, i32 0, i32 0
store i8* %49, i8** %51
%52 = load i32, i32* %7
%53 = call i32 @htons(i32 %52)
%54 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
store i32 %53, i32* %54
store i32 1, i32* %9
%55 = load i32, i32* %8
%56 = load i32, i32* @SOL_SOCKET
%57 = load i32, i32* @SO_REUSEADDR
%58 = bitcast i32* %9 to i8*
%59 = call i64 @setsockopt(i32 %55, i32 %56, i32 %57, i8* %58, i32 4)
%60 = icmp slt i64 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %44
%62 = load i32, i32* @stderr
%63 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%64 = call i32 @exit(i32 1)
unreachable
65: ; preds = %44
%66 = load i32, i32* %8
%67 = bitcast %struct.sockaddr_in* %10 to %struct.sockaddr*
%68 = call i64 @bind(i32 %66, %struct.sockaddr* %67, i32 16)
%69 = icmp slt i64 %68, 0
br i1 %69, label %70, label %74
70: ; preds = %65
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %65
%75 = load i8*, i8** %6
%76 = call i32 @inet_addr(i8* %75)
%77 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %11, i32 0, i32 1
%78 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %77, i32 0, i32 0
store i32 %76, i32* %78
%79 = load i32, i32* @INADDR_ANY
%80 = call i8* @htonl(i32 %79)
%81 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %11, i32 0, i32 0
%82 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %81, i32 0, i32 0
store i8* %80, i8** %82
%83 = load i32, i32* %8
%84 = load i32, i32* @IPPROTO_IP
%85 = load i32, i32* @IP_ADD_MEMBERSHIP
%86 = bitcast %struct.ip_mreq* %11 to i8*
%87 = call i64 @setsockopt(i32 %83, i32 %84, i32 %85, i8* %86, i32 16)
%88 = icmp slt i64 %87, 0
br i1 %88, label %89, label %93
89: ; preds = %74
%90 = load i32, i32* @stderr
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%92 = call i32 @exit(i32 1)
unreachable
93: ; preds = %74
store i32 0, i32* %12
br label %94
94: ; preds = %118, %93
%95 = load i32, i32* %12
%96 = icmp slt i32 %95, 4
br i1 %96, label %97, label %121
97: ; preds = %94
store i32 16, i32* %14
%98 = load i32, i32* %8
%99 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%100 = bitcast %struct.sockaddr_in* %13 to %struct.sockaddr*
%101 = call i32 @recvfrom(i32 %98, i8* %99, i32 255, i32 0, %struct.sockaddr* %100, i32* %14)
store i32 %101, i32* %16
%102 = load i32, i32* %16
%103 = icmp slt i32 %102, 0
br i1 %103, label %104, label %108
104: ; preds = %97
%105 = load i32, i32* @stderr
%106 = call i32 (i32, i8*, ...) @fprintf(i32 %105, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%107 = call i32 @exit(i32 1)
unreachable
108: ; preds = %97
%109 = load i32, i32* %16
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 %110
store i8 0, i8* %111
%112 = getelementptr inbounds [256 x i8], [256 x i8]* %15, i64 0, i64 0
%113 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 0
%114 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %113, i32 0, i32 0
%115 = load i8*, i8** %114
%116 = call i8* @inet_ntoa(i8* %115)
%117 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %112, i8* %116)
br label %118
118: ; preds = %108
%119 = load i32, i32* %12
%120 = add nsw i32 %119, 1
store i32 %120, i32* %12
br label %94
121: ; preds = %94
%122 = load i32, i32* %8
%123 = call i32 @close(i32 %122)
%124 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_6__, i32, i32 }
%struct.TYPE_6__ = type { i8* }
%struct.ip_mreq = type { %struct.TYPE_5__, %struct.TYPE_4__ }
%struct.TYPE_5__ = type { i8* }
%struct.TYPE_4__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [51 x i8] c"Usage: %s <Multicast IP Address> <Multicast Port>\0A\00"
@PF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_UDP = global i32 0
@.str.1 = [17 x i8] c"socket() failed\0A\00"
@AF_INET = global i32 0
@INADDR_ANY = global i32 0
@SOL_SOCKET = global i32 0
@SO_REUSEADDR = global i32 0
@.str.2 = [21 x i8] c"setsockopt() failed\0A\00"
@.str.3 = [15 x i8] c"bind() failed\0A\00"
@IPPROTO_IP = global i32 0
@IP_ADD_MEMBERSHIP = global i32 0
@.str.4 = [19 x i8] c"recvfrom() failed\0A\00"
@.str.5 = [22 x i8] c"Received: %s from %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.ip_mreq
%6 = alloca %struct.sockaddr_in
%7 = alloca i32
%8 = alloca [256 x i8]
%9 = bitcast i32* %3 to i8*
%10 = bitcast %struct.sockaddr_in* %4 to i8*
%11 = bitcast %struct.ip_mreq* %5 to i8*
%12 = bitcast %struct.sockaddr_in* %6 to i8*
%13 = bitcast i32* %7 to i8*
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%15 = icmp eq i32 %0, 3
br i1 %15, label %21, label %16
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %1
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = tail call i32 @exit(i32 1)
unreachable
21: ; preds = %2
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32 @atoi(i8* %25)
%27 = load i32, i32* @PF_INET
%28 = load i32, i32* @SOCK_DGRAM
%29 = load i32, i32* @IPPROTO_UDP
%30 = tail call i32 @socket(i32 %27, i32 %28, i32 %29)
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %21
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0))
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %21
%37 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 16)
%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 = load i32, i32* @INADDR_ANY
%41 = call i8* @htonl(i32 %40)
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i8* %41, i8** %42
%43 = call i32 @htons(i32 %26)
%44 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %43, i32* %44
store i32 1, i32* %3
%45 = load i32, i32* @SOL_SOCKET
%46 = load i32, i32* @SO_REUSEADDR
%47 = call i64 @setsockopt(i32 %30, i32 %45, i32 %46, i8* %9, i32 4)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %53
49: ; preds = %36
%50 = load i32, i32* @stderr
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%52 = call i32 @exit(i32 1)
unreachable
53: ; preds = %36
%54 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%55 = call i64 @bind(i32 %30, %struct.sockaddr* %54, i32 16)
%56 = icmp slt i64 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%60 = call i32 @exit(i32 1)
unreachable
61: ; preds = %53
%62 = call i32 @inet_addr(i8* %23)
%63 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %5, i64 0, i32 1, i32 0
store i32 %62, i32* %63
%64 = load i32, i32* @INADDR_ANY
%65 = call i8* @htonl(i32 %64)
%66 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %5, i64 0, i32 0, i32 0
store i8* %65, i8** %66
%67 = load i32, i32* @IPPROTO_IP
%68 = load i32, i32* @IP_ADD_MEMBERSHIP
%69 = call i64 @setsockopt(i32 %30, i32 %67, i32 %68, i8* %11, i32 16)
%70 = icmp slt i64 %69, 0
br i1 %70, label %76, label %71
71: ; preds = %61
%72 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%73 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i64 0, i32 0, i32 0
store i32 16, i32* %7
%74 = call i32 @recvfrom(i32 %30, i8* %14, i32 255, i32 0, %struct.sockaddr* %72, i32* %7)
%75 = icmp slt i32 %74, 0
br i1 %75, label %80, label %84
76: ; preds = %61
%77 = load i32, i32* @stderr
%78 = call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%79 = call i32 @exit(i32 1)
unreachable
80: ; preds = %100, %92, %84, %71
%81 = load i32, i32* @stderr
%82 = call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%83 = call i32 @exit(i32 1)
unreachable
84: ; preds = %71
%85 = zext i32 %74 to i64
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %85
store i8 0, i8* %86
%87 = load i8*, i8** %73
%88 = call i8* @inet_ntoa(i8* %87)
%89 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %14, i8* %88)
store i32 16, i32* %7
%90 = call i32 @recvfrom(i32 %30, i8* %14, i32 255, i32 0, %struct.sockaddr* %72, i32* %7)
%91 = icmp slt i32 %90, 0
br i1 %91, label %80, label %92
92: ; preds = %84
%93 = zext i32 %90 to i64
%94 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %93
store i8 0, i8* %94
%95 = load i8*, i8** %73
%96 = call i8* @inet_ntoa(i8* %95)
%97 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %14, i8* %96)
store i32 16, i32* %7
%98 = call i32 @recvfrom(i32 %30, i8* %14, i32 255, i32 0, %struct.sockaddr* %72, i32* %7)
%99 = icmp slt i32 %98, 0
br i1 %99, label %80, label %100
100: ; preds = %92
%101 = zext i32 %98 to i64
%102 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %101
store i8 0, i8* %102
%103 = load i8*, i8** %73
%104 = call i8* @inet_ntoa(i8* %103)
%105 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %14, i8* %104)
store i32 16, i32* %7
%106 = call i32 @recvfrom(i32 %30, i8* %14, i32 255, i32 0, %struct.sockaddr* %72, i32* %7)
%107 = icmp slt i32 %106, 0
br i1 %107, label %80, label %108
108: ; preds = %100
%109 = zext i32 %106 to i64
%110 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 %109
store i8 0, i8* %110
%111 = load i8*, i8** %73
%112 = call i8* @inet_ntoa(i8* %111)
%113 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0), i8* %14, i8* %112)
%114 = call i32 @close(i32 %30)
%115 = call i32 @exit(i32 0)
unreachable
}