#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct msghdr {
  char *msg_control;
  int msg_controllen;
  int msg_iovlen;
  struct iovec *msg_iov;
  scalar_t__ msg_flags;
  scalar_t__ msg_namelen;
  scalar_t__ msg_name;
};
struct iovec {
  long **iov_base;
  int iov_len;
};
struct cmsghdr {
  scalar_t__ cmsg_level;
  scalar_t__ cmsg_type;
  int cmsg_len;
};
typedef int /*<<< orphan*/ posn;
typedef int /*<<< orphan*/ control;

/* Variables and functions */
int /*<<< orphan*/ CMSG_DATA(struct cmsghdr *);
struct cmsghdr *CMSG_FIRSTHDR(struct msghdr *);
struct cmsghdr *CMSG_NXTHDR(struct msghdr *, struct cmsghdr *);
int CMSG_SPACE(size_t);
scalar_t__ EAGAIN;
scalar_t__ EINTR;
scalar_t__ SCM_RIGHTS;
scalar_t__ SOL_SOCKET;
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memcpy(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, long, ...);
size_t recvmsg(int, struct msghdr *, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int readUpdate(int fd, long *posn, int *newfd) {
  struct msghdr msg;
  struct iovec iov[1];
  struct cmsghdr *cmptr;
  size_t len;
  size_t msg_size = sizeof(int);
  char control[CMSG_SPACE(msg_size)];
  msg.msg_name = 0;
  msg.msg_namelen = 0;
  msg.msg_control = control;
  msg.msg_controllen = sizeof(control);
  msg.msg_flags = 0;
  msg.msg_iov = iov;
  msg.msg_iovlen = 1;
  iov[0].iov_base = &posn;
  iov[0].iov_len = sizeof(posn);
  do {
    len = recvmsg(fd, &msg, 0);
  } while (len == (size_t)(-1) && (errno == EINTR || errno == EAGAIN));
  printf("iov[0].buf is %ld\n", *((long *)iov[0].iov_base));
  printf("len is %ld\n", len);
  if (len == (size_t)(-1)) {
    perror("recvmsg()");
    return -1;
  }
  if (msg.msg_controllen < sizeof(struct cmsghdr))
    return *posn;
  for (cmptr = CMSG_FIRSTHDR(&msg); cmptr != NULL;
       cmptr = CMSG_NXTHDR(&msg, cmptr)) {
    if (cmptr->cmsg_level != SOL_SOCKET || cmptr->cmsg_type != SCM_RIGHTS) {
      printf("continuing %ld\n", sizeof(size_t));
      printf("read msg_size = %ld\n", msg_size);
      if (cmptr->cmsg_len != sizeof(control))
        printf("not equal (%ld != %ld)\n", cmptr->cmsg_len, sizeof(control));
      continue;
    }
    memcpy(newfd, CMSG_DATA(cmptr), sizeof(int));
    printf("posn is %ld (fd = %d)\n", *posn, *newfd);
    return 0;
  }
  fprintf(stderr, "bad data in packet\n");
  return -1;
}


x86 assembly (clang, -O0):
<readUpdate>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x4,-0x78(%rbp)
mov    -0x78(%rbp),%rdi
call   1050 <CMSG_SPACE@plt>
mov    %eax,%eax
mov    %rax,-0x98(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,%rsp
mov    %rax,-0x88(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    %rcx,-0x48(%rbp)
mov    %eax,-0x40(%rbp)
movq   $0x0,-0x30(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x1,-0x3c(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x60(%rbp)
movl   $0x8,-0x58(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x48(%rbp),%rsi
xor    %edx,%edx
call   1090 <recvmsg@plt>
mov    %rax,-0x70(%rbp)
xor    %eax,%eax
cmpq   $0xffffffffffffffff,-0x70(%rbp)
mov    %al,-0x99(%rbp)
jne    128f <readUpdate+0xff>
mov    0x2d85(%rip),%rax
mov    (%rax),%rcx
mov    $0x1,%al
mov    0x2d69(%rip),%rdx
cmp    (%rdx),%rcx
mov    %al,-0x9a(%rbp)
je     1283 <readUpdate+0xf3>
mov    0x2d63(%rip),%rax
mov    (%rax),%rax
mov    0x2d39(%rip),%rcx
cmp    (%rcx),%rax
sete   %al
mov    %al,-0x9a(%rbp)
mov    -0x9a(%rbp),%al
mov    %al,-0x99(%rbp)
mov    -0x99(%rbp),%al
test   $0x1,%al
jne    121f <readUpdate+0x8f>
mov    -0x60(%rbp),%rax
mov    (%rax),%rsi
lea    0xd55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x70(%rbp),%rsi
lea    0xd56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0xffffffffffffffff,-0x70(%rbp)
jne    12f1 <readUpdate+0x161>
lea    0xd49(%rip),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
jmp    1452 <readUpdate+0x2c2>
movslq -0x40(%rbp),%rax
cmp    $0x18,%rax
jae    1318 <readUpdate+0x188>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %eax,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
jmp    1452 <readUpdate+0x2c2>
lea    -0x48(%rbp),%rdi
call   10b0 <CMSG_FIRSTHDR@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     142c <readUpdate+0x29c>
mov    -0x68(%rbp),%rax
mov    (%rax),%rax
mov    0x2caa(%rip),%rcx
cmp    (%rcx),%rax
jne    135f <readUpdate+0x1cf>
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2c72(%rip),%rcx
cmp    (%rcx),%rax
je     13be <readUpdate+0x22e>
lea    0xcc3(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x78(%rbp),%rsi
lea    0xcbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x98(%rbp),%rcx
mov    -0x68(%rbp),%rax
movslq 0x10(%rax),%rax
cmp    %rcx,%rax
je     13b9 <readUpdate+0x229>
mov    -0x98(%rbp),%rdx
mov    -0x68(%rbp),%rax
movslq 0x10(%rax),%rsi
lea    0xc9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1416 <readUpdate+0x286>
mov    -0x18(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x68(%rbp),%rdi
call   1030 <CMSG_DATA@plt>
mov    -0xa8(%rbp),%rdi
mov    %eax,%esi
mov    $0x4,%edx
call   1070 <memcpy@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xc6d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
jmp    1452 <readUpdate+0x2c2>
mov    -0x68(%rbp),%rsi
lea    -0x48(%rbp),%rdi
call   1080 <CMSG_NXTHDR@plt>
mov    %rax,-0x68(%rbp)
jmp    1325 <readUpdate+0x195>
mov    0x2ba5(%rip),%rax
mov    (%rax),%edi
lea    0xc41(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
movl   $0x1,-0x8c(%rbp)
mov    -0x80(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readUpdate>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdx,-0x58(%rbp)
mov    %edi,%r12d
mov    %rsi,-0x38(%rbp)
mov    $0x4,%edi
call   1050 <CMSG_SPACE@plt>
mov    %rsp,-0x30(%rbp)
mov    %eax,%edx
mov    %rsp,%rcx
mov    %rdx,-0x60(%rbp)
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
sub    %rdx,%rcx
mov    %rcx,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,-0x70(%rbp)
mov    %rcx,-0x90(%rbp)
mov    %eax,-0x88(%rbp)
movq   $0x0,-0x78(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0x80(%rbp)
movl   $0x1,-0x84(%rbp)
lea    -0x38(%rbp),%rax
mov    %rax,-0x50(%rbp)
movl   $0x8,-0x48(%rbp)
lea    -0x90(%rbp),%r14
mov    0x2db4(%rip),%r13
mov    0x2d9d(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r12d,%edi
mov    %r14,%rsi
xor    %edx,%edx
call   1090 <recvmsg@plt>
cmp    $0xffffffffffffffff,%rax
jne    1293 <readUpdate+0x103>
mov    0x0(%r13),%rax
cmp    (%r15),%rax
je     1230 <readUpdate+0xa0>
mov    0x2d5d(%rip),%rcx
cmp    (%rcx),%rax
je     1230 <readUpdate+0xa0>
mov    -0x50(%rbp),%rax
mov    (%rax),%rsi
lea    0xd9a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd9f(%rip),%rdi
mov    $0xffffffffffffffff,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd96(%rip),%rdi
call   10a0 <perror@plt>
jmp    1391 <readUpdate+0x201>
mov    %rax,%rbx
mov    -0x50(%rbp),%rax
mov    (%rax),%rsi
lea    0xd5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd61(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x17,-0x88(%rbp)
ja     12d0 <readUpdate+0x140>
mov    -0x38(%rbp),%rax
mov    (%rax),%ebx
jmp    1396 <readUpdate+0x206>
lea    -0x90(%rbp),%rdi
call   10b0 <CMSG_FIRSTHDR@plt>
test   %rax,%rax
mov    -0x60(%rbp),%r15
je     137c <readUpdate+0x1ec>
mov    %rax,%rbx
lea    0xd36(%rip),%r12
lea    0xd3f(%rip),%r13
lea    -0x90(%rbp),%r14
jmp    1323 <readUpdate+0x193>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1080 <CMSG_NXTHDR@plt>
mov    %rax,%rbx
test   %rax,%rax
je     137c <readUpdate+0x1ec>
mov    (%rbx),%rax
mov    0x2cbb(%rip),%rcx
cmp    (%rcx),%rax
jne    1342 <readUpdate+0x1b2>
mov    0x8(%rbx),%rax
mov    0x2c8b(%rip),%rcx
cmp    (%rcx),%rax
je     13ae <readUpdate+0x21e>
mov    $0x8,%esi
mov    %r12,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x4,%esi
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x10(%rbx),%rsi
cmp    %r15,%rsi
je     1310 <readUpdate+0x180>
lea    0xcde(%rip),%rdi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1310 <readUpdate+0x180>
mov    0x2c55(%rip),%rax
mov    (%rax),%edi
lea    0xcf1(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %ebx,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1030 <CMSG_DATA@plt>
mov    -0x58(%rbp),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0x4,%edx
call   1070 <memcpy@plt>
mov    -0x38(%rbp),%rax
mov    (%rax),%rsi
mov    (%rbx),%edx
lea    0xc8d(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1396 <readUpdate+0x206>

LLVM IR (-O0):
%struct.msghdr = type { i8*, i32, i32, %struct.iovec*, i64, i64, i64 }
%struct.iovec = type { i64**, i32 }
%struct.cmsghdr = type { i64, i64, i32 }
@errno = global i64 0
@EINTR = global i64 0
@EAGAIN = global i64 0
@.str = [19 x i8] c"iov[0].buf is %ld\0A\00"
@.str.1 = [12 x i8] c"len is %ld\0A\00"
@.str.2 = [10 x i8] c"recvmsg()\00"
@SOL_SOCKET = global i64 0
@SCM_RIGHTS = global i64 0
@.str.3 = [16 x i8] c"continuing %ld\0A\00"
@.str.4 = [21 x i8] c"read msg_size = %ld\0A\00"
@.str.5 = [24 x i8] c"not equal (%ld != %ld)\0A\00"
@.str.6 = [23 x i8] c"posn is %ld (fd = %d)\0A\00"
@stderr = global i32 0
@.str.7 = [20 x i8] c"bad data in packet\0A\00"
define i32 @readUpdate(i32 %0, i64* %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i64*
%7 = alloca i32*
%8 = alloca %struct.msghdr
%9 = alloca [1 x %struct.iovec]
%10 = alloca %struct.cmsghdr*
%11 = alloca i64
%12 = alloca i64
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
store i32 %0, i32* %5
store i64* %1, i64** %6
store i32* %2, i32** %7
store i64 4, i64* %12
%16 = load i64, i64* %12
%17 = call i32 @CMSG_SPACE(i64 %16)
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %13
%20 = alloca i8, i64 %18
store i64 %18, i64* %14
%21 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %8, i32 0, i32 6
store i64 0, i64* %21
%22 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %8, i32 0, i32 5
store i64 0, i64* %22
%23 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %8, i32 0, i32 0
store i8* %20, i8** %23
%24 = trunc i64 %18 to i32
%25 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %8, i32 0, i32 1
store i32 %24, i32* %25
%26 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %8, i32 0, i32 4
store i64 0, i64* %26
%27 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %9, i64 0, i64 0
%28 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %8, i32 0, i32 3
store %struct.iovec* %27, %struct.iovec** %28
%29 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %8, i32 0, i32 2
store i32 1, i32* %29
%30 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %9, i64 0, i64 0
%31 = getelementptr inbounds %struct.iovec, %struct.iovec* %30, i32 0, i32 0
store i64** %6, i64*** %31
%32 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %9, i64 0, i64 0
%33 = getelementptr inbounds %struct.iovec, %struct.iovec* %32, i32 0, i32 1
store i32 8, i32* %33
br label %34
34: ; preds = %50, %3
%35 = load i32, i32* %5
%36 = call i64 @recvmsg(i32 %35, %struct.msghdr* %8, i32 0)
store i64 %36, i64* %11
br label %37
37: ; preds = %34
%38 = load i64, i64* %11
%39 = icmp eq i64 %38, -1
br i1 %39, label %40, label %50
40: ; preds = %37
%41 = load i64, i64* @errno
%42 = load i64, i64* @EINTR
%43 = icmp eq i64 %41, %42
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = load i64, i64* @errno
%46 = load i64, i64* @EAGAIN
%47 = icmp eq i64 %45, %46
br label %48
48: ; preds = %44, %40
%49 = phi i1 [ true, %40 ], [ %47, %44 ]
br label %50
50: ; preds = %48, %37
%51 = phi i1 [ false, %37 ], [ %49, %48 ]
br i1 %51, label %34, label %52
52: ; preds = %50
%53 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %9, i64 0, i64 0
%54 = getelementptr inbounds %struct.iovec, %struct.iovec* %53, i32 0, i32 0
%55 = load i64**, i64*** %54
%56 = bitcast i64** %55 to i64*
%57 = load i64, i64* %56
%58 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %57)
%59 = load i64, i64* %11
%60 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 %59)
%61 = load i64, i64* %11
%62 = icmp eq i64 %61, -1
br i1 %62, label %63, label %65
63: ; preds = %52
%64 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %4
store i32 1, i32* %15
br label %123
65: ; preds = %52
%66 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %8, i32 0, i32 1
%67 = load i32, i32* %66
%68 = sext i32 %67 to i64
%69 = icmp ult i64 %68, 24
br i1 %69, label %70, label %74
70: ; preds = %65
%71 = load i64*, i64** %6
%72 = load i64, i64* %71
%73 = trunc i64 %72 to i32
store i32 %73, i32* %4
store i32 1, i32* %15
br label %123
74: ; preds = %65
%75 = call %struct.cmsghdr* @CMSG_FIRSTHDR(%struct.msghdr* %8)
store %struct.cmsghdr* %75, %struct.cmsghdr** %10
br label %76
76: ; preds = %117, %74
%77 = load %struct.cmsghdr*, %struct.cmsghdr** %10
%78 = icmp ne %struct.cmsghdr* %77, null
br i1 %78, label %79, label %120
79: ; preds = %76
%80 = load %struct.cmsghdr*, %struct.cmsghdr** %10
%81 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %80, i32 0, i32 0
%82 = load i64, i64* %81
%83 = load i64, i64* @SOL_SOCKET
%84 = icmp ne i64 %82, %83
br i1 %84, label %91, label %85
85: ; preds = %79
%86 = load %struct.cmsghdr*, %struct.cmsghdr** %10
%87 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %86, i32 0, i32 1
%88 = load i64, i64* %87
%89 = load i64, i64* @SCM_RIGHTS
%90 = icmp ne i64 %88, %89
br i1 %90, label %91, label %107
91: ; preds = %85, %79
%92 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i64 8)
%93 = load i64, i64* %12
%94 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i64 %93)
%95 = load %struct.cmsghdr*, %struct.cmsghdr** %10
%96 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %95, i32 0, i32 2
%97 = load i32, i32* %96
%98 = sext i32 %97 to i64
%99 = icmp ne i64 %98, %18
br i1 %99, label %100, label %106
100: ; preds = %91
%101 = load %struct.cmsghdr*, %struct.cmsghdr** %10
%102 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %101, i32 0, i32 2
%103 = load i32, i32* %102
%104 = sext i32 %103 to i64
%105 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i64 %104, i64 %18)
br label %106
106: ; preds = %100, %91
br label %117
107: ; preds = %85
%108 = load i32*, i32** %7
%109 = load %struct.cmsghdr*, %struct.cmsghdr** %10
%110 = call i32 @CMSG_DATA(%struct.cmsghdr* %109)
%111 = call i32 @memcpy(i32* %108, i32 %110, i32 4)
%112 = load i64*, i64** %6
%113 = load i64, i64* %112
%114 = load i32*, i32** %7
%115 = load i32, i32* %114
%116 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i64 %113, i32 %115)
store i32 0, i32* %4
store i32 1, i32* %15
br label %123
117: ; preds = %106
%118 = load %struct.cmsghdr*, %struct.cmsghdr** %10
%119 = call %struct.cmsghdr* @CMSG_NXTHDR(%struct.msghdr* %8, %struct.cmsghdr* %118)
store %struct.cmsghdr* %119, %struct.cmsghdr** %10
br label %76
120: ; preds = %76
%121 = load i32, i32* @stderr
%122 = call i32 @fprintf(i32 %121, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %4
store i32 1, i32* %15
br label %123
123: ; preds = %120, %107, %70, %63
%124 = load i8*, i8** %13
%125 = load i32, i32* %4
ret i32 %125
}

LLVM IR (-O2):
%struct.msghdr = type { i8*, i32, i32, %struct.iovec*, i64, i64, i64 }
%struct.iovec = type { i64**, i32 }
%struct.cmsghdr = type { i64, i64, i32 }
@errno = global i64 0
@EINTR = global i64 0
@EAGAIN = global i64 0
@.str = [19 x i8] c"iov[0].buf is %ld\0A\00"
@.str.1 = [12 x i8] c"len is %ld\0A\00"
@.str.2 = [10 x i8] c"recvmsg()\00"
@SOL_SOCKET = global i64 0
@SCM_RIGHTS = global i64 0
@.str.3 = [16 x i8] c"continuing %ld\0A\00"
@.str.4 = [21 x i8] c"read msg_size = %ld\0A\00"
@.str.5 = [24 x i8] c"not equal (%ld != %ld)\0A\00"
@.str.6 = [23 x i8] c"posn is %ld (fd = %d)\0A\00"
@stderr = global i32 0
@.str.7 = [20 x i8] c"bad data in packet\0A\00"
define i32 @readUpdate(i32 %0, i64* %1, i32* %2) {
%4 = alloca i64*
%5 = alloca %struct.msghdr
%6 = alloca [1 x %struct.iovec]
store i64* %1, i64** %4
%7 = bitcast %struct.msghdr* %5 to i8*
%8 = bitcast [1 x %struct.iovec]* %6 to i8*
%9 = tail call i32 @CMSG_SPACE(i64 4)
%10 = zext i32 %9 to i64
%11 = tail call i8* @llvm.stacksave()
%12 = alloca i8, i64 %10
%13 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 5
%14 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 0
%15 = bitcast i64* %13 to i8*
store i8* %12, i8** %14
%16 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 1
store i32 %9, i32* %16
%17 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 4
store i64 0, i64* %17
%18 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %6, i64 0, i64 0
%19 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 3
store %struct.iovec* %18, %struct.iovec** %19
%20 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %5, i64 0, i32 2
store i32 1, i32* %20
%21 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %6, i64 0, i64 0, i32 0
store i64** %4, i64*** %21
%22 = getelementptr inbounds [1 x %struct.iovec], [1 x %struct.iovec]* %6, i64 0, i64 0, i32 1
store i32 8, i32* %22
br label %23
23: ; preds = %26, %3
%24 = call i64 @recvmsg(i32 %0, %struct.msghdr* %5, i32 0)
%25 = icmp eq i64 %24, -1
br i1 %25, label %26, label %40
26: ; preds = %23
%27 = load i64, i64* @errno
%28 = load i64, i64* @EINTR
%29 = icmp eq i64 %27, %28
%30 = load i64, i64* @EAGAIN
%31 = icmp eq i64 %27, %30
%32 = select i1 %29, i1 true, i1 %31
br i1 %32, label %23, label %33
33: ; preds = %26
%34 = bitcast [1 x %struct.iovec]* %6 to i64**
%35 = load i64*, i64** %34
%36 = load i64, i64* %35
%37 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %36)
%38 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 -1)
%39 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
br label %88
40: ; preds = %23
%41 = bitcast [1 x %struct.iovec]* %6 to i64**
%42 = load i64*, i64** %41
%43 = load i64, i64* %42
%44 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %43)
%45 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i64 %24)
%46 = load i32, i32* %16
%47 = icmp ult i32 %46, 24
br i1 %47, label %48, label %52
48: ; preds = %40
%49 = load i64*, i64** %4
%50 = load i64, i64* %49
%51 = trunc i64 %50 to i32
br label %88
52: ; preds = %40
%53 = call %struct.cmsghdr* @CMSG_FIRSTHDR(%struct.msghdr* %5)
%54 = icmp eq %struct.cmsghdr* %53, null
br i1 %54, label %85, label %55
55: ; preds = %52, %82
%56 = phi %struct.cmsghdr* [ %83, %82 ], [ %53, %52 ]
%57 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %56, i64 0, i32 0
%58 = load i64, i64* %57
%59 = load i64, i64* @SOL_SOCKET
%60 = icmp eq i64 %58, %59
br i1 %60, label %61, label %66
61: ; preds = %55
%62 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %56, i64 0, i32 1
%63 = load i64, i64* %62
%64 = load i64, i64* @SCM_RIGHTS
%65 = icmp eq i64 %63, %64
br i1 %65, label %75, label %66
66: ; preds = %61, %55
%67 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i64 8)
%68 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i64 4)
%69 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %56, i64 0, i32 2
%70 = load i32, i32* %69
%71 = sext i32 %70 to i64
%72 = icmp eq i64 %71, %10
br i1 %72, label %82, label %73
73: ; preds = %66
%74 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i64 %71, i64 %10)
br label %82
75: ; preds = %61
%76 = call i32 @CMSG_DATA(%struct.cmsghdr* %56)
%77 = call i32 @memcpy(i32* %2, i32 %76, i32 4)
%78 = load i64*, i64** %4
%79 = load i64, i64* %78
%80 = load i32, i32* %2
%81 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i64 %79, i32 %80)
br label %88
82: ; preds = %66, %73
%83 = call %struct.cmsghdr* @CMSG_NXTHDR(%struct.msghdr* %5, %struct.cmsghdr* %56)
%84 = icmp eq %struct.cmsghdr* %83, null
br i1 %84, label %85, label %55
85: ; preds = %82, %52
%86 = load i32, i32* @stderr
%87 = call i32 @fprintf(i32 %86, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0))
br label %88
88: ; preds = %85, %75, %48, %33
%89 = phi i32 [ -1, %33 ], [ %51, %48 ], [ 0, %75 ], [ -1, %85 ]
ret i32 %89
}