#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 */
typedef int uint32_t;
struct TYPE_4__ {
  int s_addr;
};
struct sockaddr_in {
  void *sin_port;
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct TYPE_6__ {
  int s_addr;
};
struct TYPE_5__ {
  int /*<<< orphan*/ s_addr;
};
struct ip_mreq {
  TYPE_3__ imr_interface;
  TYPE_2__ imr_multiaddr;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ mreq;
typedef int /*<<< orphan*/ message;
typedef int /*<<< orphan*/ data;
typedef int /*<<< orphan*/ crc;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ INADDR_ANY;
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IP_ADD_MEMBERSHIP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SHUT_RDWR;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ adler32(int);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
scalar_t__ connect(int, struct sockaddr *, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int htonl(int /*<<< orphan*/);
void *htons(int);
int /*<<< orphan*/ inet_addr(char *);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/,
                      struct ip_mreq *, int);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
scalar_t__ write(int, char *, scalar_t__);
int main(int argc, char *argv[]) {
  struct sockaddr_in addr;
  struct ip_mreq mreq;
  uint32_t data, crc;
  socklen_t addrlen;
  char message[sizeof(data) + sizeof(crc)];
  int sock;
  if (argc != 2) {
    fprintf(stderr, "usage: %s filename\n", argv[0]);
    exit(EXIT_SUCCESS);
  }
  if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
    perror("socket() failed");
    exit(EXIT_SUCCESS);
  }
  memset(&addr, 0, sizeof(addr));
  addr.sin_family = AF_INET;
  addr.sin_port = htons(2015);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  addrlen = sizeof(addr);
  if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
    perror("bind() failed");
    close(sock);
    exit(EXIT_FAILURE);
  }
  mreq.imr_multiaddr.s_addr = inet_addr("224.0.0.3");
  mreq.imr_interface.s_addr = htonl(INADDR_ANY);
  if (setsockopt(sock, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) <
      0) {
    perror("setsockopt() failed");
    close(sock);
    exit(EXIT_FAILURE);
  }
  if (recvfrom(sock, message, sizeof(message), 0, (struct sockaddr *)&addr,
               &addrlen) != (sizeof(data) + sizeof(crc))) {
    perror("recvfrom() failed");
    close(sock);
    exit(EXIT_FAILURE);
  }
  close(sock);
  data = *(uint32_t *)message;
  crc = *(uint32_t *)(message + 4);
  if (crc != htonl(adler32(data))) {
    fprintf(stderr, "0x%x != 0x%x (0x%x 0x%x)\n", crc, htonl(adler32(data)),
            data, crc);
    exit(EXIT_FAILURE);
  }
  addr.sin_port = htons(1984);
  if ((sock = socket(PF_INET, SOCK_STREAM, 0)) < 0) {
    perror("socket() (TCP) failed");
    exit(EXIT_FAILURE);
  }
  if (connect(sock, (struct sockaddr *)&addr, addrlen) < 0) {
    perror("connect() failed");
    close(sock);
    exit(EXIT_FAILURE);
  }
  if (write(sock, argv[1], strlen(argv[1])) != strlen(argv[1])) {
    perror("write() failed");
    close(sock);
    exit(EXIT_FAILURE);
  }
  shutdown(sock, SHUT_RDWR);
  close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     125c <main+0x4c>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xdb9(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
mov    0x2d54(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x40(%rbp)
cmp    $0x0,%eax
jge    129b <main+0x8b>
lea    0xd8c(%rip),%rdi
call   1100 <perror@plt>
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1090 <memset@plt>
mov    0x2d26(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    $0x7df,%edi
call   1070 <htons@plt>
mov    %rax,-0x20(%rbp)
mov    0x2cfc(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x18(%rbp)
movl   $0x10,-0x34(%rbp)
mov    -0x40(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    $0x10,%edx
call   10f0 <bind@plt>
cmp    $0x0,%rax
jge    131a <main+0x10a>
lea    0xd25(%rip),%rdi
call   1100 <perror@plt>
mov    -0x40(%rbp),%edi
call   10a0 <close@plt>
mov    0x2c85(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    0xd11(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,-0x24(%rbp)
mov    0x2c98(%rip),%rax
mov    (%rax),%edi
call   1080 <htonl@plt>
mov    %eax,-0x28(%rbp)
mov    -0x40(%rbp),%edi
mov    0x2c8c(%rip),%rax
mov    (%rax),%esi
mov    0x2c93(%rip),%rax
mov    (%rax),%edx
lea    -0x28(%rbp),%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    138a <main+0x17a>
lea    0xccd(%rip),%rdi
call   1100 <perror@plt>
mov    -0x40(%rbp),%edi
call   10a0 <close@plt>
mov    0x2c15(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x40(%rbp),%edi
lea    -0x3c(%rbp),%rsi
lea    -0x20(%rbp),%r8
mov    $0x8,%edx
xor    %ecx,%ecx
lea    -0x34(%rbp),%r9
call   10e0 <recvfrom@plt>
cltq
cmp    $0x8,%rax
je     13d3 <main+0x1c3>
lea    0xc98(%rip),%rdi
call   1100 <perror@plt>
mov    -0x40(%rbp),%edi
call   10a0 <close@plt>
mov    0x2bcc(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x40(%rbp),%edi
call   10a0 <close@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x2c(%rbp),%edi
call   10d0 <adler32@plt>
mov    %eax,%edi
call   1080 <htonl@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
je     1456 <main+0x246>
mov    0x2ba0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x2c(%rbp),%edi
call   10d0 <adler32@plt>
mov    %eax,%edi
call   1080 <htonl@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%edx
mov    %eax,%ecx
mov    -0x2c(%rbp),%r8d
mov    -0x30(%rbp),%r9d
lea    0xc21(%rip),%rsi
mov    $0x0,%al
call   10c0 <fprintf@plt>
mov    0x2b49(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    $0x7c0,%edi
call   1070 <htons@plt>
mov    %rax,-0x20(%rbp)
mov    0x2b35(%rip),%rax
mov    (%rax),%edi
mov    0x2b34(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x40(%rbp)
cmp    $0x0,%eax
jge    14a3 <main+0x293>
lea    0xbec(%rip),%rdi
call   1100 <perror@plt>
mov    0x2afc(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x40(%rbp),%edi
lea    -0x20(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   1120 <connect@plt>
cmp    $0x0,%rax
jge    14de <main+0x2ce>
lea    0xbcf(%rip),%rdi
call   1100 <perror@plt>
mov    -0x40(%rbp),%edi
call   10a0 <close@plt>
mov    0x2ac1(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x40(%rbp),%eax
mov    %eax,-0x64(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
cmp    %rcx,%rax
je     154f <main+0x33f>
lea    0xb6f(%rip),%rdi
call   1100 <perror@plt>
mov    -0x40(%rbp),%edi
call   10a0 <close@plt>
mov    0x2a50(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x40(%rbp),%edi
mov    0x2a97(%rip),%rax
mov    (%rax),%esi
call   1050 <shutdown@plt>
mov    -0x40(%rbp),%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r14
cmp    $0x2,%edi
jne    13d4 <main+0x1c4>
mov    0x2dab(%rip),%rbx
mov    (%rbx),%edi
mov    0x2d8a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
test   %eax,%eax
js     13f0 <main+0x1e0>
mov    %eax,%ebp
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1090 <memset@plt>
mov    (%rbx),%eax
mov    %eax,0x14(%rsp)
mov    $0x7df,%edi
call   1070 <htons@plt>
mov    %rax,0x8(%rsp)
mov    0x2d4f(%rip),%rbx
mov    (%rbx),%edi
call   1080 <htonl@plt>
mov    %eax,0x10(%rsp)
movl   $0x10,0x4(%rsp)
mov    %ebp,%edi
mov    %r15,%rsi
mov    $0x10,%edx
call   10f0 <bind@plt>
test   %rax,%rax
js     140a <main+0x1fa>
lea    0xd87(%rip),%rdi
call   10b0 <inet_addr@plt>
mov    %eax,0x1c(%rsp)
mov    (%rbx),%edi
call   1080 <htonl@plt>
mov    %eax,0x18(%rsp)
mov    0x2d0a(%rip),%rax
mov    (%rax),%esi
mov    0x2d11(%rip),%rax
mov    (%rax),%edx
lea    0x18(%rsp),%rcx
mov    %ebp,%edi
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     1413 <main+0x203>
lea    0x20(%rsp),%rsi
lea    0x8(%rsp),%r8
lea    0x4(%rsp),%r9
mov    %ebp,%edi
mov    $0x8,%edx
xor    %ecx,%ecx
call   10e0 <recvfrom@plt>
cmp    $0x8,%eax
jne    141c <main+0x20c>
mov    %ebp,%edi
call   10a0 <close@plt>
mov    0x20(%rsp),%ebp
mov    0x24(%rsp),%ebx
mov    %ebp,%edi
call   10d0 <adler32@plt>
mov    %eax,%edi
call   1080 <htonl@plt>
cmp    %eax,%ebx
jne    1425 <main+0x215>
mov    $0x7c0,%edi
call   1070 <htons@plt>
mov    %rax,0x8(%rsp)
mov    0x2c53(%rip),%rax
mov    (%rax),%edi
mov    0x2c52(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
test   %eax,%eax
js     145a <main+0x24a>
mov    %eax,%ebp
mov    0x4(%rsp),%edx
lea    0x8(%rsp),%rsi
mov    %eax,%edi
call   1120 <connect@plt>
test   %rax,%rax
js     1468 <main+0x258>
mov    0x8(%r14),%rbx
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %rax,%rbx
mov    0x8(%r14),%rdi
call   1060 <strlen@plt>
cmp    %rax,%rbx
jne    1471 <main+0x261>
mov    0x2c39(%rip),%rax
mov    (%rax),%esi
mov    %ebp,%edi
call   1050 <shutdown@plt>
mov    %ebp,%edi
call   10a0 <close@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bd5(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
lea    0xc19(%rip),%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    13fc <main+0x1ec>
lea    0xc1d(%rip),%rdi
call   1100 <perror@plt>
mov    0x2b8d(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    0xc13(%rip),%rdi
jmp    1478 <main+0x268>
lea    0xc22(%rip),%rdi
jmp    1478 <main+0x268>
lea    0xc2d(%rip),%rdi
jmp    1478 <main+0x268>
mov    0x2b84(%rip),%rax
mov    (%rax),%r14d
mov    %ebp,%edi
call   10d0 <adler32@plt>
mov    %eax,%edi
call   1080 <htonl@plt>
lea    0xc1e(%rip),%rsi
mov    %r14d,%edi
mov    %ebx,%edx
mov    %eax,%ecx
mov    %ebp,%r8d
mov    %ebx,%r9d
xor    %eax,%eax
call   10c0 <fprintf@plt>
jmp    1484 <main+0x274>
lea    0xc1b(%rip),%rdi
call   1100 <perror@plt>
jmp    1484 <main+0x274>
lea    0xc23(%rip),%rdi
jmp    1478 <main+0x268>
lea    0xc2b(%rip),%rdi
call   1100 <perror@plt>
mov    %ebp,%edi
call   10a0 <close@plt>
mov    0x2b0d(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i8*, %struct.TYPE_4__, i32 }
%struct.TYPE_4__ = type { i32 }
%struct.ip_mreq = type { %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [20 x i8] c"usage: %s filename\0A\00"
@EXIT_SUCCESS = global i32 0
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str.1 = [16 x i8] c"socket() failed\00"
@INADDR_ANY = global i32 0
@.str.2 = [14 x i8] c"bind() failed\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [10 x i8] c"224.0.0.3\00"
@IPPROTO_IP = global i32 0
@IP_ADD_MEMBERSHIP = global i32 0
@.str.4 = [20 x i8] c"setsockopt() failed\00"
@.str.5 = [18 x i8] c"recvfrom() failed\00"
@.str.6 = [26 x i8] c"0x%x != 0x%x (0x%x 0x%x)\0A\00"
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.7 = [22 x i8] c"socket() (TCP) failed\00"
@.str.8 = [17 x i8] c"connect() failed\00"
@.str.9 = [15 x i8] c"write() failed\00"
@SHUT_RDWR = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.sockaddr_in
%7 = alloca %struct.ip_mreq
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [8 x i8]
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %23
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 0
%19 = load i8*, i8** %18
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %19)
%21 = load i32, i32* @EXIT_SUCCESS
%22 = call i32 @exit(i32 %21)
unreachable
23: ; preds = %2
%24 = load i32, i32* @AF_INET
%25 = load i32, i32* @SOCK_DGRAM
%26 = call i32 @socket(i32 %24, i32 %25, i32 0)
store i32 %26, i32* %12
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %23
%29 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @EXIT_SUCCESS
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %23
%33 = call i32 @memset(%struct.sockaddr_in* %6, i32 0, i32 16)
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 2
store i32 %34, i32* %35
%36 = call i8* @htons(i32 2015)
%37 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i8* %36, i8** %37
%38 = load i32, i32* @INADDR_ANY
%39 = call i32 @htonl(i32 %38)
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%41 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %40, i32 0, i32 0
store i32 %39, i32* %41
store i32 16, i32* %10
%42 = load i32, i32* %12
%43 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%44 = call i64 @bind(i32 %42, %struct.sockaddr* %43, i32 16)
%45 = icmp slt i64 %44, 0
br i1 %45, label %46, label %52
46: ; preds = %32
%47 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%48 = load i32, i32* %12
%49 = call i32 @close(i32 %48)
%50 = load i32, i32* @EXIT_FAILURE
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %32
%53 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%54 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %7, i32 0, i32 1
%55 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %54, i32 0, i32 0
store i32 %53, i32* %55
%56 = load i32, i32* @INADDR_ANY
%57 = call i32 @htonl(i32 %56)
%58 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %7, i32 0, i32 0
%59 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %58, i32 0, i32 0
store i32 %57, i32* %59
%60 = load i32, i32* %12
%61 = load i32, i32* @IPPROTO_IP
%62 = load i32, i32* @IP_ADD_MEMBERSHIP
%63 = call i64 @setsockopt(i32 %60, i32 %61, i32 %62, %struct.ip_mreq* %7, i32 8)
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %71
65: ; preds = %52
%66 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%67 = load i32, i32* %12
%68 = call i32 @close(i32 %67)
%69 = load i32, i32* @EXIT_FAILURE
%70 = call i32 @exit(i32 %69)
unreachable
71: ; preds = %52
%72 = load i32, i32* %12
%73 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%74 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%75 = call i32 @recvfrom(i32 %72, i8* %73, i32 8, i32 0, %struct.sockaddr* %74, i32* %10)
%76 = sext i32 %75 to i64
%77 = icmp ne i64 %76, 8
br i1 %77, label %78, label %84
78: ; preds = %71
%79 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0))
%80 = load i32, i32* %12
%81 = call i32 @close(i32 %80)
%82 = load i32, i32* @EXIT_FAILURE
%83 = call i32 @exit(i32 %82)
unreachable
84: ; preds = %71
%85 = load i32, i32* %12
%86 = call i32 @close(i32 %85)
%87 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%88 = bitcast i8* %87 to i32*
%89 = load i32, i32* %88
store i32 %89, i32* %8
%90 = getelementptr inbounds [8 x i8], [8 x i8]* %11, i64 0, i64 0
%91 = getelementptr inbounds i8, i8* %90, i64 4
%92 = bitcast i8* %91 to i32*
%93 = load i32, i32* %92
store i32 %93, i32* %9
%94 = load i32, i32* %9
%95 = load i32, i32* %8
%96 = call i32 @adler32(i32 %95)
%97 = call i32 @htonl(i32 %96)
%98 = icmp ne i32 %94, %97
br i1 %98, label %99, label %110
99: ; preds = %84
%100 = load i32, i32* @stderr
%101 = load i32, i32* %9
%102 = load i32, i32* %8
%103 = call i32 @adler32(i32 %102)
%104 = call i32 @htonl(i32 %103)
%105 = load i32, i32* %8
%106 = load i32, i32* %9
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %100, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %101, i32 %104, i32 %105, i32 %106)
%108 = load i32, i32* @EXIT_FAILURE
%109 = call i32 @exit(i32 %108)
unreachable
110: ; preds = %84
%111 = call i8* @htons(i32 1984)
%112 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 0
store i8* %111, i8** %112
%113 = load i32, i32* @PF_INET
%114 = load i32, i32* @SOCK_STREAM
%115 = call i32 @socket(i32 %113, i32 %114, i32 0)
store i32 %115, i32* %12
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %121
117: ; preds = %110
%118 = call i32 @perror(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.7, i64 0, i64 0))
%119 = load i32, i32* @EXIT_FAILURE
%120 = call i32 @exit(i32 %119)
unreachable
121: ; preds = %110
%122 = load i32, i32* %12
%123 = bitcast %struct.sockaddr_in* %6 to %struct.sockaddr*
%124 = load i32, i32* %10
%125 = call i64 @connect(i32 %122, %struct.sockaddr* %123, i32 %124)
%126 = icmp slt i64 %125, 0
br i1 %126, label %127, label %133
127: ; preds = %121
%128 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
%129 = load i32, i32* %12
%130 = call i32 @close(i32 %129)
%131 = load i32, i32* @EXIT_FAILURE
%132 = call i32 @exit(i32 %131)
unreachable
133: ; preds = %121
%134 = load i32, i32* %12
%135 = load i8**, i8*** %5
%136 = getelementptr inbounds i8*, i8** %135, i64 1
%137 = load i8*, i8** %136
%138 = load i8**, i8*** %5
%139 = getelementptr inbounds i8*, i8** %138, i64 1
%140 = load i8*, i8** %139
%141 = call i64 @strlen(i8* %140)
%142 = call i64 @write(i32 %134, i8* %137, i64 %141)
%143 = load i8**, i8*** %5
%144 = getelementptr inbounds i8*, i8** %143, i64 1
%145 = load i8*, i8** %144
%146 = call i64 @strlen(i8* %145)
%147 = icmp ne i64 %142, %146
br i1 %147, label %148, label %154
148: ; preds = %133
%149 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%150 = load i32, i32* %12
%151 = call i32 @close(i32 %150)
%152 = load i32, i32* @EXIT_FAILURE
%153 = call i32 @exit(i32 %152)
unreachable
154: ; preds = %133
%155 = load i32, i32* %12
%156 = load i32, i32* @SHUT_RDWR
%157 = call i32 @shutdown(i32 %155, i32 %156)
%158 = load i32, i32* %12
%159 = call i32 @close(i32 %158)
ret i32 0
}

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