#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 scalar_t__ uint32_t;
struct TYPE_4__ {
  int s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  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*/ cmd;
typedef int /*<<< orphan*/ addr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ INADDR_ANY;
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IP_ADD_MEMBERSHIP;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ adler32(scalar_t__);
scalar_t__ bind(int, struct sockaddr *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, scalar_t__, int,
                           scalar_t__, scalar_t__);
int /*<<< orphan*/ get_ip_str(struct sockaddr *, char *);
int htonl(int /*<<< orphan*/);
int /*<<< orphan*/ 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*/ snprintf(char *, int, char *, char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int system(char *);
int main(void) {
  struct sockaddr_in addr;
  struct ip_mreq mreq;
  uint32_t data, crc;
  socklen_t addrlen;
  char message[sizeof(data) + sizeof(crc)], addrstr[INET6_ADDRSTRLEN],
      cmd[sizeof("ssh -X pi@%s") + INET6_ADDRSTRLEN + 1];
  int sock, ret;
  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);
  }
  get_ip_str((struct sockaddr *)&addr, addrstr);
  snprintf(cmd, sizeof(cmd), "ssh -X pi@%s", addrstr);
  ret = system(cmd);
  if (ret == -1) {
    perror("system() failed");
    exit(EXIT_FAILURE);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2dcf(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x48(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x78(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x50(%rbp)
movslq (%rax),%rdx
mov    %rdx,%rax
add    $0xe,%rax
mov    %rax,-0x70(%rbp)
add    $0x1d,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
mov    0x2d6c(%rip),%rax
mov    (%rax),%edi
mov    0x2d4b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
mov    %eax,-0x5c(%rbp)
cmp    $0x0,%eax
jge    12a4 <main+0xa4>
lea    0xd6f(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x2d1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x7df,%edi
call   1050 <htons@plt>
mov    %eax,-0xc(%rbp)
mov    0x2cf4(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x10(%rbp)
movl   $0xc,-0x2c(%rbp)
mov    -0x5c(%rbp),%edi
lea    -0x10(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
cmp    $0x0,%rax
jge    1322 <main+0x122>
lea    0xd09(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x5c(%rbp),%edi
call   1090 <close@plt>
mov    0x2c8d(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    0xcf5(%rip),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,-0x14(%rbp)
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
call   1070 <htonl@plt>
mov    %eax,-0x18(%rbp)
mov    -0x5c(%rbp),%edi
mov    0x2c84(%rip),%rax
mov    (%rax),%esi
mov    0x2c8b(%rip),%rax
mov    (%rax),%edx
lea    -0x18(%rbp),%rcx
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1392 <main+0x192>
lea    0xcb1(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x5c(%rbp),%edi
call   1090 <close@plt>
mov    0x2c1d(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x5c(%rbp),%edi
lea    -0x40(%rbp),%rsi
lea    -0x10(%rbp),%r8
mov    $0x10,%edx
xor    %ecx,%ecx
lea    -0x2c(%rbp),%r9
call   10d0 <recvfrom@plt>
cltq
cmp    $0x10,%rax
je     13db <main+0x1db>
lea    0xc7c(%rip),%rdi
call   10f0 <perror@plt>
mov    -0x5c(%rbp),%edi
call   1090 <close@plt>
mov    0x2bd4(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x5c(%rbp),%edi
call   1090 <close@plt>
mov    -0x40(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x3c(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x20(%rbp),%rdi
call   10c0 <adler32@plt>
mov    %eax,%edi
call   1070 <htonl@plt>
mov    %eax,%ecx
mov    -0x80(%rbp),%rax
movslq %ecx,%rcx
cmp    %rcx,%rax
je     1478 <main+0x278>
mov    0x2b8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x20(%rbp),%rdi
call   10c0 <adler32@plt>
mov    %eax,%edi
call   1070 <htonl@plt>
mov    -0x8c(%rbp),%edi
mov    -0x88(%rbp),%rdx
mov    %eax,%ecx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
lea    0xbe9(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2b37(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
mov    -0x78(%rbp),%rsi
lea    -0x10(%rbp),%rdi
call   1100 <get_ip_str@plt>
mov    -0x78(%rbp),%rcx
mov    -0x68(%rbp),%rdi
mov    -0x70(%rbp),%rax
mov    %eax,%esi
lea    0xbce(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x68(%rbp),%rdi
call   1040 <system@plt>
mov    %eax,-0x60(%rbp)
cmpl   $0xffffffff,-0x60(%rbp)
jne    14cf <main+0x2cf>
lea    0xbb9(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2ae0(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsp,-0x50(%rbp)
mov    0x2dcc(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%r14
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r14
mov    %r14,%rsp
movslq (%rax),%r15
mov    %rsp,%r12
lea    0x1d(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    0x2d8e(%rip),%r13
mov    0x0(%r13),%edi
mov    0x2d6b(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1120 <socket@plt>
test   %eax,%eax
js     139d <main+0x19d>
mov    %eax,%ebx
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1080 <memset@plt>
mov    0x0(%r13),%eax
mov    %eax,-0x30(%rbp)
mov    $0x7df,%edi
call   1050 <htons@plt>
mov    %eax,-0x34(%rbp)
mov    0x2d35(%rip),%r13
mov    0x0(%r13),%edi
call   1070 <htonl@plt>
mov    %eax,-0x38(%rbp)
movl   $0xc,-0x3c(%rbp)
mov    %ebx,%edi
lea    -0x38(%rbp),%rsi
mov    $0xc,%edx
call   10e0 <bind@plt>
test   %rax,%rax
js     13b7 <main+0x1b7>
lea    0xd58(%rip),%rdi
call   10a0 <inet_addr@plt>
mov    %eax,-0x44(%rbp)
mov    0x0(%r13),%edi
call   1070 <htonl@plt>
mov    %eax,-0x48(%rbp)
mov    0x2cef(%rip),%rax
mov    (%rax),%esi
mov    0x2cf6(%rip),%rax
mov    (%rax),%edx
lea    -0x48(%rbp),%rcx
mov    %ebx,%edi
mov    $0x8,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     13c0 <main+0x1c0>
lea    -0x60(%rbp),%rsi
lea    -0x38(%rbp),%r8
lea    -0x3c(%rbp),%r9
mov    %ebx,%edi
mov    $0x10,%edx
xor    %ecx,%ecx
call   10d0 <recvfrom@plt>
cmp    $0x10,%eax
jne    13c9 <main+0x1c9>
mov    %ebx,%edi
call   1090 <close@plt>
mov    -0x60(%rbp),%rbx
mov    -0x5c(%rbp),%r13
mov    %rbx,%rdi
call   10c0 <adler32@plt>
mov    %eax,%edi
call   1070 <htonl@plt>
cltq
cmp    %rax,%r13
jne    13de <main+0x1de>
add    $0xe,%r15
lea    -0x38(%rbp),%rdi
mov    %r14,%rsi
call   1100 <get_ip_str@plt>
lea    0xcff(%rip),%rdx
mov    %r12,%rdi
mov    %r15d,%esi
mov    %r14,%rcx
call   1060 <snprintf@plt>
mov    %r12,%rdi
call   1040 <system@plt>
cmp    $0xffffffff,%eax
je     1413 <main+0x213>
mov    -0x50(%rbp),%rsp
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc5c(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2bf0(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>
lea    0xc52(%rip),%rdi
jmp    13d0 <main+0x1d0>
lea    0xc61(%rip),%rdi
jmp    13d0 <main+0x1d0>
lea    0xc6c(%rip),%rdi
call   10f0 <perror@plt>
mov    %ebx,%edi
call   1090 <close@plt>
jmp    141f <main+0x21f>
mov    0x2bcb(%rip),%rax
mov    (%rax),%r14d
mov    %rbx,%rdi
call   10c0 <adler32@plt>
mov    %eax,%edi
call   1070 <htonl@plt>
lea    0xc50(%rip),%rsi
mov    %r14d,%edi
mov    %r13,%rdx
mov    %eax,%ecx
mov    %rbx,%r8
mov    %r13,%r9
call   10b0 <fprintf@plt>
jmp    141f <main+0x21f>
lea    0xc5b(%rip),%rdi
call   10f0 <perror@plt>
mov    0x2b82(%rip),%rax
mov    (%rax),%edi
call   1110 <exit@plt>

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

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_4__, i32, 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 }
@INET6_ADDRSTRLEN = global i32 0
@AF_INET = global i32 0
@SOCK_DGRAM = global i32 0
@.str = [16 x i8] c"socket() failed\00"
@EXIT_SUCCESS = global i32 0
@INADDR_ANY = global i32 0
@.str.1 = [14 x i8] c"bind() failed\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [10 x i8] c"224.0.0.3\00"
@IPPROTO_IP = global i32 0
@IP_ADD_MEMBERSHIP = global i32 0
@.str.3 = [20 x i8] c"setsockopt() failed\00"
@.str.4 = [18 x i8] c"recvfrom() failed\00"
@stderr = global i32 0
@.str.5 = [26 x i8] c"0x%x != 0x%x (0x%x 0x%x)\0A\00"
@.str.6 = [13 x i8] c"ssh -X pi@%s\00"
@.str.7 = [16 x i8] c"system() failed\00"
define i32 @main() {
%1 = alloca %struct.sockaddr_in
%2 = alloca %struct.ip_mreq
%3 = alloca i32
%4 = alloca [16 x i8]
%5 = bitcast %struct.sockaddr_in* %1 to i8*
%6 = bitcast %struct.ip_mreq* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%9 = load i32, i32* @INET6_ADDRSTRLEN
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = load i32, i32* @INET6_ADDRSTRLEN
%14 = sext i32 %13 to i64
%15 = add nsw i64 %14, 14
%16 = alloca i8, i64 %15
%17 = load i32, i32* @AF_INET
%18 = load i32, i32* @SOCK_DGRAM
%19 = tail call i32 @socket(i32 %17, i32 %18, i32 0)
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %0
%22 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%23 = load i32, i32* @EXIT_SUCCESS
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %0
%26 = call i32 @memset(%struct.sockaddr_in* %1, i32 0, i32 12)
%27 = load i32, i32* @AF_INET
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 2
store i32 %27, i32* %28
%29 = call i32 @htons(i32 2015)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1
store i32 %29, i32* %30
%31 = load i32, i32* @INADDR_ANY
%32 = call i32 @htonl(i32 %31)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0, i32 0
store i32 %32, i32* %33
store i32 12, i32* %3
%34 = bitcast %struct.sockaddr_in* %1 to %struct.sockaddr*
%35 = call i64 @bind(i32 %19, %struct.sockaddr* %34, i32 12)
%36 = icmp slt i64 %35, 0
br i1 %36, label %37, label %42
37: ; preds = %25
%38 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%39 = call i32 @close(i32 %19)
%40 = load i32, i32* @EXIT_FAILURE
%41 = call i32 @exit(i32 %40)
unreachable
42: ; preds = %25
%43 = call i32 @inet_addr(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%44 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %2, i64 0, i32 1, i32 0
store i32 %43, i32* %44
%45 = load i32, i32* @INADDR_ANY
%46 = call i32 @htonl(i32 %45)
%47 = getelementptr inbounds %struct.ip_mreq, %struct.ip_mreq* %2, i64 0, i32 0, i32 0
store i32 %46, i32* %47
%48 = load i32, i32* @IPPROTO_IP
%49 = load i32, i32* @IP_ADD_MEMBERSHIP
%50 = call i64 @setsockopt(i32 %19, i32 %48, i32 %49, %struct.ip_mreq* %2, i32 8)
%51 = icmp slt i64 %50, 0
br i1 %51, label %52, label %57
52: ; preds = %42
%53 = call i32 @perror(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%54 = call i32 @close(i32 %19)
%55 = load i32, i32* @EXIT_FAILURE
%56 = call i32 @exit(i32 %55)
unreachable
57: ; preds = %42
%58 = call i32 @recvfrom(i32 %19, i8* %8, i32 16, i32 0, %struct.sockaddr* %34, i32* %3)
%59 = icmp eq i32 %58, 16
br i1 %59, label %65, label %60
60: ; preds = %57
%61 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%62 = call i32 @close(i32 %19)
%63 = load i32, i32* @EXIT_FAILURE
%64 = call i32 @exit(i32 %63)
unreachable
65: ; preds = %57
%66 = call i32 @close(i32 %19)
%67 = bitcast [16 x i8]* %4 to i64*
%68 = load i64, i64* %67
%69 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 4
%70 = bitcast i8* %69 to i64*
%71 = load i64, i64* %70
%72 = call i32 @adler32(i64 %68)
%73 = call i32 @htonl(i32 %72)
%74 = sext i32 %73 to i64
%75 = icmp eq i64 %71, %74
br i1 %75, label %83, label %76
76: ; preds = %65
%77 = load i32, i32* @stderr
%78 = call i32 @adler32(i64 %68)
%79 = call i32 @htonl(i32 %78)
%80 = call i32 @fprintf(i32 %77, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i64 %71, i32 %79, i64 %68, i64 %71)
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %65
%84 = call i32 @get_ip_str(%struct.sockaddr* %34, i8* %12)
%85 = trunc i64 %15 to i32
%86 = call i32 @snprintf(i8* %16, i32 %85, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %12)
%87 = call i32 @system(i8* %16)
%88 = icmp eq i32 %87, -1
br i1 %88, label %89, label %93
89: ; preds = %83
%90 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
%91 = load i32, i32* @EXIT_FAILURE
%92 = call i32 @exit(i32 %91)
unreachable
93: ; preds = %83
ret i32 0
}