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

/* Forward declarations */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ uint8_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct msghdr {
  char *msg_control;
  int msg_controllen;
  int msg_namelen;
  int msg_iovlen;
  scalar_t__ msg_flags;
  struct iovec *msg_iov;
  struct sockaddr_in *msg_name;
};
struct iovec {
  size_t iov_len;
  int /*<<< orphan*/ *iov_base;
};
struct in_pktinfo {
  int ipi_ifindex;
  TYPE_1__ ipi_addr;
};
struct cmsghdr {
  scalar_t__ cmsg_level;
  scalar_t__ cmsg_type;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ si;
typedef int /*<<< orphan*/ cbuf;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
scalar_t__ CMSG_DATA(struct cmsghdr *);
struct cmsghdr *CMSG_FIRSTHDR(struct msghdr *);
struct cmsghdr *CMSG_NXTHDR(struct msghdr *, struct cmsghdr *);
scalar_t__ IP_PKTINFO;
scalar_t__ SOL_IP;
scalar_t__ getsockname(int, struct sockaddr *, int *);
int /*<<< orphan*/ memset(struct msghdr *, int /*<<< orphan*/, int);
int /*<<< orphan*/ ntohl(int /*<<< orphan*/);
int /*<<< orphan*/ ntohs(int /*<<< orphan*/);
int recvmsg(int, struct msghdr *, int /*<<< orphan*/);
int recvfromto(int fd, uint8_t *buf, size_t len, struct sockaddr_in *from,
               socklen_t *fromlen, struct sockaddr_in *to, socklen_t *tolen,
               int *ifindex) {
  struct msghdr msgh;
  struct cmsghdr *cmsg;
  struct iovec iov;
  char cbuf[1000];
  int err;
  if (to) {
    struct sockaddr_in si;
    socklen_t si_len = sizeof(si);
    ((struct sockaddr_in *)to)->sin_family = AF_INET;
    if (getsockname(fd, (struct sockaddr *)&si, &si_len)) {
      ((struct sockaddr_in *)to)->sin_port = ntohs(0);
      ((struct sockaddr_in *)to)->sin_addr.s_addr = ntohl(0);
    } else {
      ((struct sockaddr_in *)to)->sin_port = si.sin_port;
      ((struct sockaddr_in *)to)->sin_addr = si.sin_addr;
    }
    if (tolen)
      *tolen = sizeof(si);
  }
  memset(&msgh, 0, sizeof(struct msghdr));
  iov.iov_base = buf;
  iov.iov_len = len;
  msgh.msg_control = cbuf;
  msgh.msg_controllen = sizeof(cbuf);
  msgh.msg_name = from;
  msgh.msg_namelen = fromlen ? *fromlen : 0;
  msgh.msg_iov = &iov;
  msgh.msg_iovlen = 1;
  msgh.msg_flags = 0;
  err = recvmsg(fd, &msgh, 0);
  if (err < 0)
    return err;
  if (fromlen)
    *fromlen = msgh.msg_namelen;
  for (cmsg = CMSG_FIRSTHDR(&msgh); cmsg != NULL;
       cmsg = CMSG_NXTHDR(&msgh, cmsg)) {
    if ((cmsg->cmsg_level == SOL_IP) && (cmsg->cmsg_type == IP_PKTINFO)) {
      struct in_pktinfo *i = (struct in_pktinfo *)CMSG_DATA(cmsg);
      if (to)
        ((struct sockaddr_in *)to)->sin_addr = i->ipi_addr;
      if (tolen)
        *tolen = sizeof(struct sockaddr_in);
      if (ifindex)
        *ifindex = i->ipi_ifindex;
      break;
    }
  }
  return err;
}


x86 assembly (clang, -O0):
<recvfromto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1246 <recvfromto+0xc6>
movl   $0xc,-0x474(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x8(%rbp),%edi
lea    -0x470(%rbp),%rsi
lea    -0x474(%rbp),%rdx
call   1080 <getsockname@plt>
cmp    $0x0,%rax
je     1213 <recvfromto+0x93>
xor    %edi,%edi
call   1070 <ntohs@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x4(%rax)
xor    %edi,%edi
call   10a0 <ntohl@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
jmp    122c <recvfromto+0xac>
mov    -0x46c(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x30(%rbp),%rax
mov    -0x470(%rbp),%ecx
mov    %ecx,(%rax)
cmpq   $0x0,0x10(%rbp)
je     1241 <recvfromto+0xc1>
mov    0x10(%rbp),%rax
movl   $0xc,(%rax)
jmp    1246 <recvfromto+0xc6>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
lea    -0x460(%rbp),%rax
mov    %rax,-0x60(%rbp)
movl   $0x3e8,-0x58(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     129c <recvfromto+0x11c>
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x484(%rbp)
jmp    12a9 <recvfromto+0x129>
xor    %eax,%eax
mov    %eax,-0x484(%rbp)
jmp    12a9 <recvfromto+0x129>
mov    -0x484(%rbp),%eax
mov    %eax,-0x54(%rbp)
lea    -0x78(%rbp),%rax
mov    %rax,-0x40(%rbp)
movl   $0x1,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x60(%rbp),%rsi
xor    %edx,%edx
call   1060 <recvmsg@plt>
mov    %eax,-0x464(%rbp)
cmpl   $0x0,-0x464(%rbp)
jge    12f8 <recvfromto+0x178>
mov    -0x464(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13d6 <recvfromto+0x256>
cmpq   $0x0,-0x28(%rbp)
je     130c <recvfromto+0x18c>
mov    -0x54(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x60(%rbp),%rdi
call   1090 <CMSG_FIRSTHDR@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     13cd <recvfromto+0x24d>
mov    -0x68(%rbp),%rax
mov    (%rax),%rax
mov    0x2cc6(%rip),%rcx
cmp    (%rcx),%rax
jne    13b2 <recvfromto+0x232>
mov    -0x68(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2c8e(%rip),%rcx
cmp    (%rcx),%rax
jne    13b2 <recvfromto+0x232>
mov    -0x68(%rbp),%rdi
call   1030 <CMSG_DATA@plt>
mov    %rax,-0x480(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     137e <recvfromto+0x1fe>
mov    -0x30(%rbp),%rax
mov    -0x480(%rbp),%rcx
mov    0x4(%rcx),%ecx
mov    %ecx,(%rax)
cmpq   $0x0,0x10(%rbp)
je     1393 <recvfromto+0x213>
mov    0x10(%rbp),%rax
movl   $0xc,(%rax)
cmpq   $0x0,0x18(%rbp)
je     13ad <recvfromto+0x22d>
mov    -0x480(%rbp),%rax
mov    (%rax),%ecx
mov    0x18(%rbp),%rax
mov    %ecx,(%rax)
jmp    13cd <recvfromto+0x24d>
jmp    13b7 <recvfromto+0x237>
mov    -0x68(%rbp),%rsi
lea    -0x60(%rbp),%rdi
call   1050 <CMSG_NXTHDR@plt>
mov    %rax,-0x68(%rbp)
jmp    1319 <recvfromto+0x199>
mov    -0x464(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recvfromto>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x438,%rsp
mov    %r9,%r14
mov    %r8,%rbx
mov    %rcx,0x38(%rsp)
mov    %rdx,%r12
mov    %rsi,%r13
mov    %edi,%ebp
mov    0x470(%rsp),%r15
test   %r9,%r9
je     120b <recvfromto+0x8b>
movl   $0xc,0x8(%rsp)
mov    0x2e20(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%r14)
lea    0x50(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %ebp,%edi
call   1080 <getsockname@plt>
test   %rax,%rax
je     11f0 <recvfromto+0x70>
xor    %edi,%edi
call   1070 <ntohs@plt>
mov    %eax,0x4(%r14)
xor    %edi,%edi
call   10a0 <ntohl@plt>
jmp    11fc <recvfromto+0x7c>
mov    0x54(%rsp),%eax
mov    %eax,0x4(%r14)
mov    0x50(%rsp),%eax
mov    %eax,(%r14)
test   %r15,%r15
je     120b <recvfromto+0x8b>
movl   $0xc,(%r15)
lea    0x8(%rsp),%rdi
xor    %r15d,%r15d
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
mov    %r13,0x48(%rsp)
mov    %r12,0x40(%rsp)
lea    0x50(%rsp),%rax
mov    %rax,0x8(%rsp)
movl   $0x3e8,0x10(%rsp)
mov    0x38(%rsp),%rax
mov    %rax,0x30(%rsp)
test   %rbx,%rbx
je     124d <recvfromto+0xcd>
mov    (%rbx),%r15d
mov    %r15d,0x14(%rsp)
lea    0x40(%rsp),%rax
mov    %rax,0x28(%rsp)
movl   $0x1,0x18(%rsp)
movq   $0x0,0x20(%rsp)
lea    0x8(%rsp),%rsi
mov    %ebp,%edi
xor    %edx,%edx
call   1060 <recvmsg@plt>
mov    %eax,%r12d
test   %eax,%eax
js     1313 <recvfromto+0x193>
test   %rbx,%rbx
je     1291 <recvfromto+0x111>
mov    0x14(%rsp),%eax
mov    %eax,(%rbx)
lea    0x8(%rsp),%rdi
call   1090 <CMSG_FIRSTHDR@plt>
test   %rax,%rax
je     1313 <recvfromto+0x193>
mov    0x478(%rsp),%r15
mov    0x2d49(%rip),%rbp
mov    0x2d22(%rip),%r13
lea    0x8(%rsp),%rbx
jmp    12d0 <recvfromto+0x150>
nopl   (%rax)
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <CMSG_NXTHDR@plt>
test   %rax,%rax
je     1313 <recvfromto+0x193>
mov    (%rax),%rcx
cmp    0x0(%rbp),%rcx
jne    12c0 <recvfromto+0x140>
mov    0x8(%rax),%rcx
cmp    0x0(%r13),%rcx
jne    12c0 <recvfromto+0x140>
mov    %rax,%rdi
call   1030 <CMSG_DATA@plt>
test   %r14,%r14
je     12f6 <recvfromto+0x176>
mov    0x4(%rax),%ecx
mov    %ecx,(%r14)
mov    0x470(%rsp),%rcx
test   %rcx,%rcx
je     1309 <recvfromto+0x189>
movl   $0xc,(%rcx)
test   %r15,%r15
je     1313 <recvfromto+0x193>
mov    (%rax),%eax
mov    %eax,(%r15)
mov    %r12d,%eax
add    $0x438,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.msghdr = type { i8*, i32, i32, i32, i64, %struct.iovec*, %struct.sockaddr_in* }
%struct.iovec = type { i64, i32* }
%struct.cmsghdr = type { i64, i64 }
%struct.in_pktinfo = type { i32, %struct.TYPE_2__ }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOL_IP = global i64 0
@IP_PKTINFO = global i64 0
define i32 @recvfromto(i32 %0, i32* %1, i64 %2, %struct.sockaddr_in* %3, i32* %4, %struct.sockaddr_in* %5, i32* %6, i32* %7) {
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i64
%13 = alloca %struct.sockaddr_in*
%14 = alloca i32*
%15 = alloca %struct.sockaddr_in*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca %struct.msghdr
%19 = alloca %struct.cmsghdr*
%20 = alloca %struct.iovec
%21 = alloca [1000 x i8]
%22 = alloca i32
%23 = alloca %struct.sockaddr_in
%24 = alloca i32
%25 = alloca %struct.in_pktinfo*
store i32 %0, i32* %10
store i32* %1, i32** %11
store i64 %2, i64* %12
store %struct.sockaddr_in* %3, %struct.sockaddr_in** %13
store i32* %4, i32** %14
store %struct.sockaddr_in* %5, %struct.sockaddr_in** %15
store i32* %6, i32** %16
store i32* %7, i32** %17
%26 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%27 = icmp ne %struct.sockaddr_in* %26, null
br i1 %27, label %28, label %60
28: ; preds = %8
store i32 12, i32* %24
%29 = load i32, i32* @AF_INET
%30 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%31 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %30, i32 0, i32 2
store i32 %29, i32* %31
%32 = load i32, i32* %10
%33 = bitcast %struct.sockaddr_in* %23 to %struct.sockaddr*
%34 = call i64 @getsockname(i32 %32, %struct.sockaddr* %33, i32* %24)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %28
%37 = call i32 @ntohs(i32 0)
%38 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%39 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %38, i32 0, i32 1
store i32 %37, i32* %39
%40 = call i32 @ntohl(i32 0)
%41 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %41, i32 0, i32 0
%43 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %42, i32 0, i32 0
store i32 %40, i32* %43
br label %54
44: ; preds = %28
%45 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %23, i32 0, i32 1
%46 = load i32, i32* %45
%47 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%48 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %47, i32 0, i32 1
store i32 %46, i32* %48
%49 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %49, i32 0, i32 0
%51 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %23, i32 0, i32 0
%52 = bitcast %struct.TYPE_2__* %50 to i8*
%53 = bitcast %struct.TYPE_2__* %51 to i8*
br label %54
54: ; preds = %44, %36
%55 = load i32*, i32** %16
%56 = icmp ne i32* %55, null
br i1 %56, label %57, label %59
57: ; preds = %54
%58 = load i32*, i32** %16
store i32 12, i32* %58
br label %59
59: ; preds = %57, %54
br label %60
60: ; preds = %59, %8
%61 = call i32 @memset(%struct.msghdr* %18, i32 0, i32 48)
%62 = load i32*, i32** %11
%63 = getelementptr inbounds %struct.iovec, %struct.iovec* %20, i32 0, i32 1
store i32* %62, i32** %63
%64 = load i64, i64* %12
%65 = getelementptr inbounds %struct.iovec, %struct.iovec* %20, i32 0, i32 0
store i64 %64, i64* %65
%66 = getelementptr inbounds [1000 x i8], [1000 x i8]* %21, i64 0, i64 0
%67 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %18, i32 0, i32 0
store i8* %66, i8** %67
%68 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %18, i32 0, i32 1
store i32 1000, i32* %68
%69 = load %struct.sockaddr_in*, %struct.sockaddr_in** %13
%70 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %18, i32 0, i32 6
store %struct.sockaddr_in* %69, %struct.sockaddr_in** %70
%71 = load i32*, i32** %14
%72 = icmp ne i32* %71, null
br i1 %72, label %73, label %76
73: ; preds = %60
%74 = load i32*, i32** %14
%75 = load i32, i32* %74
br label %77
76: ; preds = %60
br label %77
77: ; preds = %76, %73
%78 = phi i32 [ %75, %73 ], [ 0, %76 ]
%79 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %18, i32 0, i32 2
store i32 %78, i32* %79
%80 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %18, i32 0, i32 5
store %struct.iovec* %20, %struct.iovec** %80
%81 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %18, i32 0, i32 3
store i32 1, i32* %81
%82 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %18, i32 0, i32 4
store i64 0, i64* %82
%83 = load i32, i32* %10
%84 = call i32 @recvmsg(i32 %83, %struct.msghdr* %18, i32 0)
store i32 %84, i32* %22
%85 = load i32, i32* %22
%86 = icmp slt i32 %85, 0
br i1 %86, label %87, label %89
87: ; preds = %77
%88 = load i32, i32* %22
store i32 %88, i32* %9
br label %146
89: ; preds = %77
%90 = load i32*, i32** %14
%91 = icmp ne i32* %90, null
br i1 %91, label %92, label %96
92: ; preds = %89
%93 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %18, i32 0, i32 2
%94 = load i32, i32* %93
%95 = load i32*, i32** %14
store i32 %94, i32* %95
br label %96
96: ; preds = %92, %89
%97 = call %struct.cmsghdr* @CMSG_FIRSTHDR(%struct.msghdr* %18)
store %struct.cmsghdr* %97, %struct.cmsghdr** %19
br label %98
98: ; preds = %141, %96
%99 = load %struct.cmsghdr*, %struct.cmsghdr** %19
%100 = icmp ne %struct.cmsghdr* %99, null
br i1 %100, label %101, label %144
101: ; preds = %98
%102 = load %struct.cmsghdr*, %struct.cmsghdr** %19
%103 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %102, i32 0, i32 0
%104 = load i64, i64* %103
%105 = load i64, i64* @SOL_IP
%106 = icmp eq i64 %104, %105
br i1 %106, label %107, label %140
107: ; preds = %101
%108 = load %struct.cmsghdr*, %struct.cmsghdr** %19
%109 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %108, i32 0, i32 1
%110 = load i64, i64* %109
%111 = load i64, i64* @IP_PKTINFO
%112 = icmp eq i64 %110, %111
br i1 %112, label %113, label %140
113: ; preds = %107
%114 = load %struct.cmsghdr*, %struct.cmsghdr** %19
%115 = call i64 @CMSG_DATA(%struct.cmsghdr* %114)
%116 = inttoptr i64 %115 to %struct.in_pktinfo*
store %struct.in_pktinfo* %116, %struct.in_pktinfo** %25
%117 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%118 = icmp ne %struct.sockaddr_in* %117, null
br i1 %118, label %119, label %126
119: ; preds = %113
%120 = load %struct.sockaddr_in*, %struct.sockaddr_in** %15
%121 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %120, i32 0, i32 0
%122 = load %struct.in_pktinfo*, %struct.in_pktinfo** %25
%123 = getelementptr inbounds %struct.in_pktinfo, %struct.in_pktinfo* %122, i32 0, i32 1
%124 = bitcast %struct.TYPE_2__* %121 to i8*
%125 = bitcast %struct.TYPE_2__* %123 to i8*
br label %126
126: ; preds = %119, %113
%127 = load i32*, i32** %16
%128 = icmp ne i32* %127, null
br i1 %128, label %129, label %131
129: ; preds = %126
%130 = load i32*, i32** %16
store i32 12, i32* %130
br label %131
131: ; preds = %129, %126
%132 = load i32*, i32** %17
%133 = icmp ne i32* %132, null
br i1 %133, label %134, label %139
134: ; preds = %131
%135 = load %struct.in_pktinfo*, %struct.in_pktinfo** %25
%136 = getelementptr inbounds %struct.in_pktinfo, %struct.in_pktinfo* %135, i32 0, i32 0
%137 = load i32, i32* %136
%138 = load i32*, i32** %17
store i32 %137, i32* %138
br label %139
139: ; preds = %134, %131
br label %144
140: ; preds = %107, %101
br label %141
141: ; preds = %140
%142 = load %struct.cmsghdr*, %struct.cmsghdr** %19
%143 = call %struct.cmsghdr* @CMSG_NXTHDR(%struct.msghdr* %18, %struct.cmsghdr* %142)
store %struct.cmsghdr* %143, %struct.cmsghdr** %19
br label %98
144: ; preds = %139, %98
%145 = load i32, i32* %22
store i32 %145, i32* %9
br label %146
146: ; preds = %144, %87
%147 = load i32, i32* %9
ret i32 %147
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.msghdr = type { i8*, i32, i32, i32, i64, %struct.iovec*, %struct.sockaddr_in* }
%struct.iovec = type { i64, i32* }
%struct.sockaddr = type { i32 }
%struct.cmsghdr = type { i64, i64 }
%struct.in_pktinfo = type { i32, %struct.TYPE_2__ }
@AF_INET = global i32 0
@SOL_IP = global i64 0
@IP_PKTINFO = global i64 0
define i32 @recvfromto(i32 %0, i32* %1, i64 %2, %struct.sockaddr_in* %3, i32* %4, %struct.sockaddr_in* writeonly %5, i32* writeonly %6, i32* writeonly %7) {
%9 = alloca %struct.msghdr
%10 = alloca %struct.iovec
%11 = alloca [1000 x i8]
%12 = alloca %struct.sockaddr_in
%13 = alloca i32
%14 = bitcast %struct.msghdr* %9 to i8*
%15 = bitcast %struct.iovec* %10 to i8*
%16 = getelementptr inbounds [1000 x i8], [1000 x i8]* %11, i64 0, i64 0
%17 = icmp eq %struct.sockaddr_in* %5, null
br i1 %17, label %42, label %18
18: ; preds = %8
%19 = bitcast %struct.sockaddr_in* %12 to i8*
%20 = bitcast i32* %13 to i8*
store i32 12, i32* %13
%21 = load i32, i32* @AF_INET
%22 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %21, i32* %22
%23 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%24 = call i64 @getsockname(i32 %0, %struct.sockaddr* %23, i32* %13)
%25 = icmp eq i64 %24, 0
br i1 %25, label %31, label %26
26: ; preds = %18
%27 = call i32 @ntohs(i32 0)
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i32 %27, i32* %28
%29 = call i32 @ntohl(i32 0)
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
store i32 %29, i32* %30
br label %38
31: ; preds = %18
%32 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i64 0, i32 1
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i32 %33, i32* %34
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i64 0, i32 0, i32 0
%36 = getelementptr %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
%37 = load i32, i32* %35
store i32 %37, i32* %36
br label %38
38: ; preds = %31, %26
%39 = icmp eq i32* %6, null
br i1 %39, label %41, label %40
40: ; preds = %38
store i32 12, i32* %6
br label %41
41: ; preds = %40, %38
br label %42
42: ; preds = %41, %8
%43 = call i32 @memset(%struct.msghdr* %9, i32 0, i32 48)
%44 = getelementptr inbounds %struct.iovec, %struct.iovec* %10, i64 0, i32 1
store i32* %1, i32** %44
%45 = getelementptr inbounds %struct.iovec, %struct.iovec* %10, i64 0, i32 0
store i64 %2, i64* %45
%46 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i64 0, i32 0
store i8* %16, i8** %46
%47 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i64 0, i32 1
store i32 1000, i32* %47
%48 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i64 0, i32 6
store %struct.sockaddr_in* %3, %struct.sockaddr_in** %48
%49 = icmp eq i32* %4, null
br i1 %49, label %52, label %50
50: ; preds = %42
%51 = load i32, i32* %4
br label %52
52: ; preds = %42, %50
%53 = phi i32 [ %51, %50 ], [ 0, %42 ]
%54 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i64 0, i32 2
store i32 %53, i32* %54
%55 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i64 0, i32 5
store %struct.iovec* %10, %struct.iovec** %55
%56 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i64 0, i32 3
store i32 1, i32* %56
%57 = getelementptr inbounds %struct.msghdr, %struct.msghdr* %9, i64 0, i32 4
store i64 0, i64* %57
%58 = call i32 @recvmsg(i32 %0, %struct.msghdr* %9, i32 0)
%59 = icmp slt i32 %58, 0
br i1 %59, label %95, label %60
60: ; preds = %52
br i1 %49, label %63, label %61
61: ; preds = %60
%62 = load i32, i32* %54
store i32 %62, i32* %4
br label %63
63: ; preds = %61, %60
%64 = call %struct.cmsghdr* @CMSG_FIRSTHDR(%struct.msghdr* %9)
%65 = icmp eq %struct.cmsghdr* %64, null
br i1 %65, label %95, label %66
66: ; preds = %63, %92
%67 = phi %struct.cmsghdr* [ %93, %92 ], [ %64, %63 ]
%68 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %67, i64 0, i32 0
%69 = load i64, i64* %68
%70 = load i64, i64* @SOL_IP
%71 = icmp eq i64 %69, %70
br i1 %71, label %72, label %92
72: ; preds = %66
%73 = getelementptr inbounds %struct.cmsghdr, %struct.cmsghdr* %67, i64 0, i32 1
%74 = load i64, i64* %73
%75 = load i64, i64* @IP_PKTINFO
%76 = icmp eq i64 %74, %75
br i1 %76, label %77, label %92
77: ; preds = %72
%78 = call i64 @CMSG_DATA(%struct.cmsghdr* %67)
%79 = inttoptr i64 %78 to %struct.in_pktinfo*
br i1 %17, label %84, label %80
80: ; preds = %77
%81 = getelementptr inbounds %struct.in_pktinfo, %struct.in_pktinfo* %79, i64 0, i32 1, i32 0
%82 = getelementptr %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
%83 = load i32, i32* %81
store i32 %83, i32* %82
br label %84
84: ; preds = %80, %77
%85 = icmp eq i32* %6, null
br i1 %85, label %87, label %86
86: ; preds = %84
store i32 12, i32* %6
br label %87
87: ; preds = %86, %84
%88 = icmp eq i32* %7, null
br i1 %88, label %95, label %89
89: ; preds = %87
%90 = getelementptr inbounds %struct.in_pktinfo, %struct.in_pktinfo* %79, i64 0, i32 0
%91 = load i32, i32* %90
store i32 %91, i32* %7
br label %95
92: ; preds = %66, %72
%93 = call %struct.cmsghdr* @CMSG_NXTHDR(%struct.msghdr* %9, %struct.cmsghdr* %67)
%94 = icmp eq %struct.cmsghdr* %93, null
br i1 %94, label %95, label %66
95: ; preds = %92, %63, %89, %87, %52
ret i32 %58
}