#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 */
typedef int socklen_t;
typedef int /*<<< orphan*/ flag;

/* Variables and functions */
scalar_t__ ENOPROTOOPT;
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IP_HDRINCL;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ err(int, char *);
scalar_t__ errno;
int /*<<< orphan*/ errx(int, char *, int, ...);
int geteuid();
scalar_t__ getsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *,
                      int *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strerror(scalar_t__);
int /*<<< orphan*/ warnx(char *, int);
void test_ip_hdrincl(void) {
  int flag[2], sock;
  socklen_t len;
  sock = socket(PF_INET, SOCK_STREAM, 0);
  if (sock == -1)
    err(-1, "test_ip_hdrincl(): socket(SOCK_STREAM)");
  flag[0] = -1;
  len = sizeof(flag[0]);
  if (getsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, &len) == 0)
    err(-1, "test_ip_hdrincl(): initial getsockopt(IP_HDRINCL)");
  if (errno != ENOPROTOOPT)
    errx(-1,
         "test_ip_hdrincl(): initial getsockopt(IP_HDRINC) "
         "returned %d (%s) not ENOPROTOOPT",
         errno, strerror(errno));
  flag[0] = 1;
  if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, sizeof(flag[0])) == 0)
    err(-1, "test_ip_hdrincl(): setsockopt(IP_HDRINCL) on TCP "
            "succeeded\n");
  if (errno != ENOPROTOOPT)
    errx(-1,
         "test_ip_hdrincl(): setsockopt(IP_HDRINCL) on TCP "
         "returned %d (%s) not ENOPROTOOPT\n",
         errno, strerror(errno));
  close(sock);
  sock = socket(PF_INET, SOCK_DGRAM, 0);
  if (sock == -1)
    err(-1, "test_ip_hdrincl(): socket(SOCK_DGRAM");
  flag[0] = -1;
  len = sizeof(flag[0]);
  if (getsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, &len) == 0)
    err(-1, "test_ip_hdrincl(): getsockopt(IP_HDRINCL) on UDP "
            "succeeded\n");
  if (errno != ENOPROTOOPT)
    errx(-1,
         "test_ip_hdrincl(): getsockopt(IP_HDRINCL) on UDP "
         "returned %d (%s) not ENOPROTOOPT\n",
         errno, strerror(errno));
  if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, sizeof(flag[0])) == 0)
    err(-1, "test_ip_hdrincl(): setsockopt(IP_HDRINCL) on UDP "
            "succeeded\n");
  if (errno != ENOPROTOOPT)
    errx(-1,
         "test_ip_hdrincl(): setsockopt(IP_HDRINCL) on UDP "
         "returned %d (%s) not ENOPROTOOPT\n",
         errno, strerror(errno));
  close(sock);
  sock = socket(PF_INET, SOCK_RAW, 0);
  if (geteuid() != 0) {
    if (sock != -1)
      errx(-1,
           "test_ip_hdrincl: created raw socket as "
           "uid %d",
           geteuid());
    return;
  }
  if (sock == -1)
    err(-1, "test_ip_hdrincl(): socket(PF_INET, SOCK_RAW)");
  flag[0] = -1;
  flag[1] = -1;
  len = sizeof(flag);
  if (getsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, &len) < 0)
    err(-1, "test_ip_hdrincl(): getsockopt(IP_HDRINCL) on raw "
            "socket");
  if (len != sizeof(flag[0]))
    errx(-1,
         "test_ip_hdrincl(): %d bytes returned on "
         "initial get\n",
         len);
  if (flag[0] != 0)
    errx(-1, "test_ip_hdrincl(): initial flag value of %d\n", flag[0]);
  flag[0] = 1;
  if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, sizeof(flag[0])) < 0)
    err(-1, "test_ip_hdrincl(): setsockopt(IP_HDRINCL, 1)");
  flag[0] = -1;
  flag[1] = -1;
  len = sizeof(flag);
  if (getsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, &len) < 0)
    err(-1, "test_ip_hdrincl(): getsockopt(IP_HDRINCL) after "
            "set");
  if (flag[0] == 0)
    errx(-1,
         "test_ip_hdrincl(): getsockopt(IP_HDRINCL) "
         "after set had flag of %d\n",
         flag[0]);
  if (flag[0] != 8)
    warnx("test_ip_hdrincl(): WARNING: getsockopt(IP_H"
          "DRINCL) after set had non-historical value of %d\n",
          flag[0]);
  flag[0] = 0;
  if (setsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, sizeof(flag[0])) < 0)
    err(-1, "test_ip_hdrincl(): setsockopt(IP_HDRINCL, 0)");
  flag[0] = -1;
  flag[1] = -1;
  len = sizeof(flag);
  if (getsockopt(sock, IPPROTO_IP, IP_HDRINCL, flag, &len) < 0)
    err(-1, "test_ip_hdrincl(): getsockopt(IP_HDRINCL) after "
            "reset");
  if (flag[0] != 0)
    errx(-1,
         "test_ip_hdrincl(): getsockopt(IP_HDRINCL) "
         "after set had flag of %d\n",
         flag[0]);
  close(sock);
}


x86 assembly (clang, -O0):
<test_ip_hdrincl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
mov    0x2e10(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    11cf <test_ip_hdrincl+0x3f>
mov    $0xffffffff,%edi
lea    0xe36(%rip),%rsi
call   1090 <err@plt>
movl   $0xffffffff,-0x8(%rbp)
movl   $0x4,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
mov    0x2e00(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%r8
call   1080 <getsockopt@plt>
cmp    $0x0,%rax
jne    121a <test_ip_hdrincl+0x8a>
mov    $0xffffffff,%edi
lea    0xe12(%rip),%rsi
call   1090 <err@plt>
mov    0x2d8f(%rip),%rax
mov    (%rax),%rax
mov    0x2db5(%rip),%rcx
cmp    (%rcx),%rax
je     1268 <test_ip_hdrincl+0xd8>
mov    0x2d75(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x14(%rbp)
mov    0x2d68(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    -0x14(%rbp),%edx
mov    %eax,%ecx
mov    $0xffffffff,%edi
lea    0xdf8(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
movl   $0x1,-0x8(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2d57(%rip),%rax
mov    (%rax),%esi
mov    0x2d6e(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jne    12ae <test_ip_hdrincl+0x11e>
mov    $0xffffffff,%edi
lea    0xe02(%rip),%rsi
call   1090 <err@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%rax
mov    0x2d21(%rip),%rcx
cmp    (%rcx),%rax
je     12fc <test_ip_hdrincl+0x16c>
mov    0x2ce1(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x18(%rbp)
mov    0x2cd4(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
mov    $0xffffffff,%edi
lea    0xdf2(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    0x2c9d(%rip),%rax
mov    (%rax),%edi
mov    0x2cb4(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    133b <test_ip_hdrincl+0x1ab>
mov    $0xffffffff,%edi
lea    0xe04(%rip),%rsi
call   1090 <err@plt>
movl   $0xffffffff,-0x8(%rbp)
movl   $0x4,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2c7d(%rip),%rax
mov    (%rax),%esi
mov    0x2c94(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%r8
call   1080 <getsockopt@plt>
cmp    $0x0,%rax
jne    1386 <test_ip_hdrincl+0x1f6>
mov    $0xffffffff,%edi
lea    0xdde(%rip),%rsi
call   1090 <err@plt>
mov    0x2c23(%rip),%rax
mov    (%rax),%rax
mov    0x2c49(%rip),%rcx
cmp    (%rcx),%rax
je     13d4 <test_ip_hdrincl+0x244>
mov    0x2c09(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x1c(%rbp)
mov    0x2bfc(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    -0x1c(%rbp),%edx
mov    %eax,%ecx
mov    $0xffffffff,%edi
lea    0xdce(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    -0xc(%rbp),%edi
mov    0x2bf2(%rip),%rax
mov    (%rax),%esi
mov    0x2c09(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jne    1413 <test_ip_hdrincl+0x283>
mov    $0xffffffff,%edi
lea    0xde0(%rip),%rsi
call   1090 <err@plt>
mov    0x2b96(%rip),%rax
mov    (%rax),%rax
mov    0x2bbc(%rip),%rcx
cmp    (%rcx),%rax
je     1461 <test_ip_hdrincl+0x2d1>
mov    0x2b7c(%rip),%rax
mov    (%rax),%rax
mov    %eax,-0x20(%rbp)
mov    0x2b6f(%rip),%rax
mov    (%rax),%rdi
call   10a0 <strerror@plt>
mov    -0x20(%rbp),%edx
mov    %eax,%ecx
mov    $0xffffffff,%edi
lea    0xdd0(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
mov    0x2b38(%rip),%rax
mov    (%rax),%edi
mov    0x2b5f(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <geteuid@plt>
cmp    $0x0,%eax
je     14c0 <test_ip_hdrincl+0x330>
cmpl   $0xffffffff,-0xc(%rbp)
je     14bb <test_ip_hdrincl+0x32b>
mov    $0x0,%al
call   1060 <geteuid@plt>
mov    %eax,%edx
mov    $0xffffffff,%edi
lea    0xdc9(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
jmp    1702 <test_ip_hdrincl+0x572>
cmpl   $0xffffffff,-0xc(%rbp)
jne    14db <test_ip_hdrincl+0x34b>
mov    $0xffffffff,%edi
lea    0xdd5(%rip),%rsi
call   1090 <err@plt>
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0x4(%rbp)
movl   $0x8,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2ad6(%rip),%rax
mov    (%rax),%esi
mov    0x2aed(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%r8
call   1080 <getsockopt@plt>
cmp    $0x0,%rax
jge    152d <test_ip_hdrincl+0x39d>
mov    $0xffffffff,%edi
lea    0xdb0(%rip),%rsi
call   1090 <err@plt>
movslq -0x10(%rbp),%rax
cmp    $0x4,%rax
je     1551 <test_ip_hdrincl+0x3c1>
mov    -0x10(%rbp),%edx
mov    $0xffffffff,%edi
lea    0xdc6(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
cmpl   $0x0,-0x8(%rbp)
je     1571 <test_ip_hdrincl+0x3e1>
mov    -0x8(%rbp),%edx
mov    $0xffffffff,%edi
lea    0xddb(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
movl   $0x1,-0x8(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2a4e(%rip),%rax
mov    (%rax),%esi
mov    0x2a65(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    15b7 <test_ip_hdrincl+0x427>
mov    $0xffffffff,%edi
lea    0xdc0(%rip),%rsi
call   1090 <err@plt>
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0x4(%rbp)
movl   $0x8,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    0x29fa(%rip),%rax
mov    (%rax),%esi
mov    0x2a11(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%r8
call   1080 <getsockopt@plt>
cmp    $0x0,%rax
jge    1609 <test_ip_hdrincl+0x479>
mov    $0xffffffff,%edi
lea    0xd9b(%rip),%rsi
call   1090 <err@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1629 <test_ip_hdrincl+0x499>
mov    -0x8(%rbp),%edx
mov    $0xffffffff,%edi
lea    0xdb1(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
cmpl   $0x8,-0x8(%rbp)
je     1642 <test_ip_hdrincl+0x4b2>
mov    -0x8(%rbp),%esi
lea    0xdda(%rip),%rdi
call   1050 <warnx@plt>
movl   $0x0,-0x8(%rbp)
mov    -0xc(%rbp),%edi
mov    0x297d(%rip),%rax
mov    (%rax),%esi
mov    0x2994(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1688 <test_ip_hdrincl+0x4f8>
mov    $0xffffffff,%edi
lea    0xdf1(%rip),%rsi
call   1090 <err@plt>
movl   $0xffffffff,-0x8(%rbp)
movl   $0xffffffff,-0x4(%rbp)
movl   $0x8,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2929(%rip),%rax
mov    (%rax),%esi
mov    0x2940(%rip),%rax
mov    (%rax),%edx
lea    -0x8(%rbp),%rcx
lea    -0x10(%rbp),%r8
call   1080 <getsockopt@plt>
cmp    $0x0,%rax
jge    16da <test_ip_hdrincl+0x54a>
mov    $0xffffffff,%edi
lea    0xdcc(%rip),%rsi
call   1090 <err@plt>
cmpl   $0x0,-0x8(%rbp)
je     16fa <test_ip_hdrincl+0x56a>
mov    -0x8(%rbp),%edx
mov    $0xffffffff,%edi
lea    0xce0(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    -0xc(%rbp),%edi
call   1070 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ip_hdrincl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
mov    0x2e0a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    11cf <test_ip_hdrincl+0x3f>
lea    0xe3b(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
movl   $0xffffffff,0x10(%rsp)
ff
movl   $0x4,0xc(%rsp)
mov    0x2dea(%rip),%r14
mov    (%r14),%esi
mov    0x2e00(%rip),%r15
mov    (%r15),%edx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %ebp,%edi
call   1080 <getsockopt@plt>
test   %rax,%rax
jne    121a <test_ip_hdrincl+0x8a>
lea    0xe17(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
mov    0x2d8f(%rip),%r13
mov    0x0(%r13),%rbx
mov    0x2db4(%rip),%r12
cmp    (%r12),%rbx
je     1251 <test_ip_hdrincl+0xc1>
mov    %rbx,%rdi
call   10a0 <strerror@plt>
lea    0xe18(%rip),%rsi
mov    $0xffffffff,%edi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <errx@plt>
movl   $0x1,0x10(%rsp)
mov    (%r14),%esi
mov    (%r15),%edx
lea    0x10(%rsp),%rcx
mov    %ebp,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
jne    1287 <test_ip_hdrincl+0xf7>
lea    0xe2e(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
mov    0x0(%r13),%rbx
cmp    (%r12),%rbx
je     12b0 <test_ip_hdrincl+0x120>
mov    %rbx,%rdi
call   10a0 <strerror@plt>
lea    0xe47(%rip),%rsi
mov    $0xffffffff,%edi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <errx@plt>
mov    %ebp,%edi
call   1070 <close@plt>
mov    0x2cea(%rip),%rax
mov    (%rax),%edi
mov    0x2d01(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    12e8 <test_ip_hdrincl+0x158>
lea    0xe5c(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
movl   $0xffffffff,0x10(%rsp)
ff
movl   $0x4,0xc(%rsp)
mov    (%r14),%esi
mov    (%r15),%edx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %ebx,%edi
call   1080 <getsockopt@plt>
test   %rax,%rax
jne    1325 <test_ip_hdrincl+0x195>
lea    0xe44(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
mov    0x0(%r13),%rbp
cmp    (%r12),%rbp
je     134e <test_ip_hdrincl+0x1be>
mov    %rbp,%rdi
call   10a0 <strerror@plt>
lea    0xe5d(%rip),%rsi
mov    $0xffffffff,%edi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <errx@plt>
mov    (%r14),%esi
mov    (%r15),%edx
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
jne    137c <test_ip_hdrincl+0x1ec>
lea    0xe7c(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
mov    0x0(%r13),%rbp
cmp    (%r12),%rbp
je     13a5 <test_ip_hdrincl+0x215>
mov    %rbp,%rdi
call   10a0 <strerror@plt>
lea    0xe95(%rip),%rsi
mov    $0xffffffff,%edi
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <errx@plt>
mov    %ebx,%edi
call   1070 <close@plt>
mov    0x2bf5(%rip),%rax
mov    (%rax),%edi
mov    0x2c1c(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   10b0 <socket@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <geteuid@plt>
test   %eax,%eax
je     13fc <test_ip_hdrincl+0x26c>
cmp    $0xffffffff,%ebx
je     15ae <test_ip_hdrincl+0x41e>
xor    %eax,%eax
call   1060 <geteuid@plt>
lea    0xe94(%rip),%rsi
mov    $0xffffffff,%edi
mov    %eax,%edx
xor    %eax,%eax
call   1040 <errx@plt>
jmp    15ae <test_ip_hdrincl+0x41e>
cmp    $0xffffffff,%ebx
jne    1412 <test_ip_hdrincl+0x282>
lea    0xea3(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
movq   $0xffffffffffffffff,0x10(%rsp)
ff ff
movl   $0x8,0xc(%rsp)
mov    (%r14),%esi
mov    (%r15),%edx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %ebx,%edi
call   1080 <getsockopt@plt>
test   %rax,%rax
jns    1450 <test_ip_hdrincl+0x2c0>
lea    0xe92(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
mov    0xc(%rsp),%edx
cmp    $0x4,%edx
je     146c <test_ip_hdrincl+0x2dc>
lea    0xeb0(%rip),%rsi
mov    $0xffffffff,%edi
xor    %eax,%eax
call   1040 <errx@plt>
mov    0x10(%rsp),%edx
test   %edx,%edx
je     1487 <test_ip_hdrincl+0x2f7>
lea    0xeca(%rip),%rsi
mov    $0xffffffff,%edi
xor    %eax,%eax
call   1040 <errx@plt>
movl   $0x1,0x10(%rsp)
mov    (%r14),%esi
mov    (%r15),%edx
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    14bd <test_ip_hdrincl+0x32d>
lea    0xebf(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
movq   $0xffffffffffffffff,0x10(%rsp)
ff ff
movl   $0x8,0xc(%rsp)
mov    (%r14),%esi
mov    (%r15),%edx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %ebx,%edi
call   1080 <getsockopt@plt>
test   %rax,%rax
jns    14fb <test_ip_hdrincl+0x36b>
lea    0xeae(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
mov    0x10(%rsp),%esi
test   %esi,%esi
je     15bd <test_ip_hdrincl+0x42d>
cmp    $0x8,%esi
je     1518 <test_ip_hdrincl+0x388>
lea    0xf04(%rip),%rdi
call   1050 <warnx@plt>
movl   $0x0,0x10(%rsp)
mov    (%r14),%esi
mov    (%r15),%edx
lea    0x10(%rsp),%rcx
mov    %ebx,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    154e <test_ip_hdrincl+0x3be>
lea    0xf30(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
movq   $0xffffffffffffffff,0x10(%rsp)
ff ff
movl   $0x8,0xc(%rsp)
mov    (%r14),%esi
mov    (%r15),%edx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %ebx,%edi
call   1080 <getsockopt@plt>
test   %rax,%rax
jns    158c <test_ip_hdrincl+0x3fc>
lea    0xf1f(%rip),%rsi
mov    $0xffffffff,%edi
call   1090 <err@plt>
mov    0x10(%rsp),%edx
test   %edx,%edx
je     15a7 <test_ip_hdrincl+0x417>
lea    0xe38(%rip),%rsi
mov    $0xffffffff,%edi
xor    %eax,%eax
call   1040 <errx@plt>
mov    %ebx,%edi
call   1070 <close@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe0f(%rip),%rsi
mov    $0xffffffff,%edi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <errx@plt>
mov    0x10(%rsp),%esi
cmp    $0x8,%esi
jne    150c <test_ip_hdrincl+0x37c>
jmp    1518 <test_ip_hdrincl+0x388>

LLVM IR (-O0):
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [39 x i8] c"test_ip_hdrincl(): socket(SOCK_STREAM)\00"
@IPPROTO_IP = global i32 0
@IP_HDRINCL = global i32 0
@.str.1 = [50 x i8] c"test_ip_hdrincl(): initial getsockopt(IP_HDRINCL)\00"
@errno = global i64 0
@ENOPROTOOPT = global i64 0
@.str.2 = [82 x i8] c"test_ip_hdrincl(): initial getsockopt(IP_HDRINC) returned %d (%s) not ENOPROTOOPT\00"
@.str.3 = [60 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL) on TCP succeeded\0A\00"
@.str.4 = [83 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL) on TCP returned %d (%s) not ENOPROTOOPT\0A\00"
@SOCK_DGRAM = global i32 0
@.str.5 = [37 x i8] c"test_ip_hdrincl(): socket(SOCK_DGRAM\00"
@.str.6 = [60 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) on UDP succeeded\0A\00"
@.str.7 = [83 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) on UDP returned %d (%s) not ENOPROTOOPT\0A\00"
@.str.8 = [60 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL) on UDP succeeded\0A\00"
@.str.9 = [83 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL) on UDP returned %d (%s) not ENOPROTOOPT\0A\00"
@SOCK_RAW = global i32 0
@.str.10 = [46 x i8] c"test_ip_hdrincl: created raw socket as uid %d\00"
@.str.11 = [45 x i8] c"test_ip_hdrincl(): socket(PF_INET, SOCK_RAW)\00"
@.str.12 = [56 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) on raw socket\00"
@.str.13 = [53 x i8] c"test_ip_hdrincl(): %d bytes returned on initial get\0A\00"
@.str.14 = [45 x i8] c"test_ip_hdrincl(): initial flag value of %d\0A\00"
@.str.15 = [45 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL, 1)\00"
@.str.16 = [52 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) after set\00"
@.str.17 = [68 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) after set had flag of %d\0A\00"
@.str.18 = [93 x i8] c"test_ip_hdrincl(): WARNING: getsockopt(IP_HDRINCL) after set had non-historical value of %d\0A\00"
@.str.19 = [45 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL, 0)\00"
@.str.20 = [54 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) after reset\00"
define void @test_ip_hdrincl() {
%1 = alloca [2 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @PF_INET
%5 = load i32, i32* @SOCK_STREAM
%6 = call i32 @socket(i32 %4, i32 %5, i32 0)
store i32 %6, i32* %2
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 @err(i32 -1, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 -1, i32* %12
store i32 4, i32* %3
%13 = load i32, i32* %2
%14 = load i32, i32* @IPPROTO_IP
%15 = load i32, i32* @IP_HDRINCL
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%17 = call i64 @getsockopt(i32 %13, i32 %14, i32 %15, i32* %16, i32* %3)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %11
%20 = call i32 @err(i32 -1, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %11
%22 = load i64, i64* @errno
%23 = load i64, i64* @ENOPROTOOPT
%24 = icmp ne i64 %22, %23
br i1 %24, label %25, label %31
25: ; preds = %21
%26 = load i64, i64* @errno
%27 = trunc i64 %26 to i32
%28 = load i64, i64* @errno
%29 = call i32 @strerror(i64 %28)
%30 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %29)
br label %31
31: ; preds = %25, %21
%32 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 1, i32* %32
%33 = load i32, i32* %2
%34 = load i32, i32* @IPPROTO_IP
%35 = load i32, i32* @IP_HDRINCL
%36 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%37 = call i64 @setsockopt(i32 %33, i32 %34, i32 %35, i32* %36, i32 4)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %31
%40 = call i32 @err(i32 -1, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %31
%42 = load i64, i64* @errno
%43 = load i64, i64* @ENOPROTOOPT
%44 = icmp ne i64 %42, %43
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = load i64, i64* @errno
%47 = trunc i64 %46 to i32
%48 = load i64, i64* @errno
%49 = call i32 @strerror(i64 %48)
%50 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.4, i64 0, i64 0), i32 %47, i32 %49)
br label %51
51: ; preds = %45, %41
%52 = load i32, i32* %2
%53 = call i32 @close(i32 %52)
%54 = load i32, i32* @PF_INET
%55 = load i32, i32* @SOCK_DGRAM
%56 = call i32 @socket(i32 %54, i32 %55, i32 0)
store i32 %56, i32* %2
%57 = load i32, i32* %2
%58 = icmp eq i32 %57, -1
br i1 %58, label %59, label %61
59: ; preds = %51
%60 = call i32 @err(i32 -1, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
br label %61
61: ; preds = %59, %51
%62 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 -1, i32* %62
store i32 4, i32* %3
%63 = load i32, i32* %2
%64 = load i32, i32* @IPPROTO_IP
%65 = load i32, i32* @IP_HDRINCL
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%67 = call i64 @getsockopt(i32 %63, i32 %64, i32 %65, i32* %66, i32* %3)
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %71
69: ; preds = %61
%70 = call i32 @err(i32 -1, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
br label %71
71: ; preds = %69, %61
%72 = load i64, i64* @errno
%73 = load i64, i64* @ENOPROTOOPT
%74 = icmp ne i64 %72, %73
br i1 %74, label %75, label %81
75: ; preds = %71
%76 = load i64, i64* @errno
%77 = trunc i64 %76 to i32
%78 = load i64, i64* @errno
%79 = call i32 @strerror(i64 %78)
%80 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.7, i64 0, i64 0), i32 %77, i32 %79)
br label %81
81: ; preds = %75, %71
%82 = load i32, i32* %2
%83 = load i32, i32* @IPPROTO_IP
%84 = load i32, i32* @IP_HDRINCL
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%86 = call i64 @setsockopt(i32 %82, i32 %83, i32 %84, i32* %85, i32 4)
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %90
88: ; preds = %81
%89 = call i32 @err(i32 -1, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.8, i64 0, i64 0))
br label %90
90: ; preds = %88, %81
%91 = load i64, i64* @errno
%92 = load i64, i64* @ENOPROTOOPT
%93 = icmp ne i64 %91, %92
br i1 %93, label %94, label %100
94: ; preds = %90
%95 = load i64, i64* @errno
%96 = trunc i64 %95 to i32
%97 = load i64, i64* @errno
%98 = call i32 @strerror(i64 %97)
%99 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.9, i64 0, i64 0), i32 %96, i32 %98)
br label %100
100: ; preds = %94, %90
%101 = load i32, i32* %2
%102 = call i32 @close(i32 %101)
%103 = load i32, i32* @PF_INET
%104 = load i32, i32* @SOCK_RAW
%105 = call i32 @socket(i32 %103, i32 %104, i32 0)
store i32 %105, i32* %2
%106 = call i32 (...) @geteuid()
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %115
108: ; preds = %100
%109 = load i32, i32* %2
%110 = icmp ne i32 %109, -1
br i1 %110, label %111, label %114
111: ; preds = %108
%112 = call i32 (...) @geteuid()
%113 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.10, i64 0, i64 0), i32 %112)
br label %114
114: ; preds = %111, %108
br label %215
115: ; preds = %100
%116 = load i32, i32* %2
%117 = icmp eq i32 %116, -1
br i1 %117, label %118, label %120
118: ; preds = %115
%119 = call i32 @err(i32 -1, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
br label %120
120: ; preds = %118, %115
%121 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 -1, i32* %121
%122 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
store i32 -1, i32* %122
store i32 8, i32* %3
%123 = load i32, i32* %2
%124 = load i32, i32* @IPPROTO_IP
%125 = load i32, i32* @IP_HDRINCL
%126 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%127 = call i64 @getsockopt(i32 %123, i32 %124, i32 %125, i32* %126, i32* %3)
%128 = icmp slt i64 %127, 0
br i1 %128, label %129, label %131
129: ; preds = %120
%130 = call i32 @err(i32 -1, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.12, i64 0, i64 0))
br label %131
131: ; preds = %129, %120
%132 = load i32, i32* %3
%133 = sext i32 %132 to i64
%134 = icmp ne i64 %133, 4
br i1 %134, label %135, label %138
135: ; preds = %131
%136 = load i32, i32* %3
%137 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.13, i64 0, i64 0), i32 %136)
br label %138
138: ; preds = %135, %131
%139 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%140 = load i32, i32* %139
%141 = icmp ne i32 %140, 0
br i1 %141, label %142, label %146
142: ; preds = %138
%143 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%144 = load i32, i32* %143
%145 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0), i32 %144)
br label %146
146: ; preds = %142, %138
%147 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 1, i32* %147
%148 = load i32, i32* %2
%149 = load i32, i32* @IPPROTO_IP
%150 = load i32, i32* @IP_HDRINCL
%151 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%152 = call i64 @setsockopt(i32 %148, i32 %149, i32 %150, i32* %151, i32 4)
%153 = icmp slt i64 %152, 0
br i1 %153, label %154, label %156
154: ; preds = %146
%155 = call i32 @err(i32 -1, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.15, i64 0, i64 0))
br label %156
156: ; preds = %154, %146
%157 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 -1, i32* %157
%158 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
store i32 -1, i32* %158
store i32 8, i32* %3
%159 = load i32, i32* %2
%160 = load i32, i32* @IPPROTO_IP
%161 = load i32, i32* @IP_HDRINCL
%162 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%163 = call i64 @getsockopt(i32 %159, i32 %160, i32 %161, i32* %162, i32* %3)
%164 = icmp slt i64 %163, 0
br i1 %164, label %165, label %167
165: ; preds = %156
%166 = call i32 @err(i32 -1, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.16, i64 0, i64 0))
br label %167
167: ; preds = %165, %156
%168 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%169 = load i32, i32* %168
%170 = icmp eq i32 %169, 0
br i1 %170, label %171, label %175
171: ; preds = %167
%172 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%173 = load i32, i32* %172
%174 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.17, i64 0, i64 0), i32 %173)
br label %175
175: ; preds = %171, %167
%176 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%177 = load i32, i32* %176
%178 = icmp ne i32 %177, 8
br i1 %178, label %179, label %183
179: ; preds = %175
%180 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%181 = load i32, i32* %180
%182 = call i32 @warnx(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.18, i64 0, i64 0), i32 %181)
br label %183
183: ; preds = %179, %175
%184 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 0, i32* %184
%185 = load i32, i32* %2
%186 = load i32, i32* @IPPROTO_IP
%187 = load i32, i32* @IP_HDRINCL
%188 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%189 = call i64 @setsockopt(i32 %185, i32 %186, i32 %187, i32* %188, i32 4)
%190 = icmp slt i64 %189, 0
br i1 %190, label %191, label %193
191: ; preds = %183
%192 = call i32 @err(i32 -1, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.19, i64 0, i64 0))
br label %193
193: ; preds = %191, %183
%194 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 -1, i32* %194
%195 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
store i32 -1, i32* %195
store i32 8, i32* %3
%196 = load i32, i32* %2
%197 = load i32, i32* @IPPROTO_IP
%198 = load i32, i32* @IP_HDRINCL
%199 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%200 = call i64 @getsockopt(i32 %196, i32 %197, i32 %198, i32* %199, i32* %3)
%201 = icmp slt i64 %200, 0
br i1 %201, label %202, label %204
202: ; preds = %193
%203 = call i32 @err(i32 -1, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.20, i64 0, i64 0))
br label %204
204: ; preds = %202, %193
%205 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%206 = load i32, i32* %205
%207 = icmp ne i32 %206, 0
br i1 %207, label %208, label %212
208: ; preds = %204
%209 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
%210 = load i32, i32* %209
%211 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.17, i64 0, i64 0), i32 %210)
br label %212
212: ; preds = %208, %204
%213 = load i32, i32* %2
%214 = call i32 @close(i32 %213)
br label %215
215: ; preds = %212, %114
ret void
}

LLVM IR (-O2):
@PF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str = [39 x i8] c"test_ip_hdrincl(): socket(SOCK_STREAM)\00"
@IPPROTO_IP = global i32 0
@IP_HDRINCL = global i32 0
@.str.1 = [50 x i8] c"test_ip_hdrincl(): initial getsockopt(IP_HDRINCL)\00"
@errno = global i64 0
@ENOPROTOOPT = global i64 0
@.str.2 = [82 x i8] c"test_ip_hdrincl(): initial getsockopt(IP_HDRINC) returned %d (%s) not ENOPROTOOPT\00"
@.str.3 = [60 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL) on TCP succeeded\0A\00"
@.str.4 = [83 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL) on TCP returned %d (%s) not ENOPROTOOPT\0A\00"
@SOCK_DGRAM = global i32 0
@.str.5 = [37 x i8] c"test_ip_hdrincl(): socket(SOCK_DGRAM\00"
@.str.6 = [60 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) on UDP succeeded\0A\00"
@.str.7 = [83 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) on UDP returned %d (%s) not ENOPROTOOPT\0A\00"
@.str.8 = [60 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL) on UDP succeeded\0A\00"
@.str.9 = [83 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL) on UDP returned %d (%s) not ENOPROTOOPT\0A\00"
@SOCK_RAW = global i32 0
@.str.10 = [46 x i8] c"test_ip_hdrincl: created raw socket as uid %d\00"
@.str.11 = [45 x i8] c"test_ip_hdrincl(): socket(PF_INET, SOCK_RAW)\00"
@.str.12 = [56 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) on raw socket\00"
@.str.13 = [53 x i8] c"test_ip_hdrincl(): %d bytes returned on initial get\0A\00"
@.str.14 = [45 x i8] c"test_ip_hdrincl(): initial flag value of %d\0A\00"
@.str.15 = [45 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL, 1)\00"
@.str.16 = [52 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) after set\00"
@.str.17 = [68 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) after set had flag of %d\0A\00"
@.str.18 = [93 x i8] c"test_ip_hdrincl(): WARNING: getsockopt(IP_HDRINCL) after set had non-historical value of %d\0A\00"
@.str.19 = [45 x i8] c"test_ip_hdrincl(): setsockopt(IP_HDRINCL, 0)\00"
@.str.20 = [54 x i8] c"test_ip_hdrincl(): getsockopt(IP_HDRINCL) after reset\00"
define void @test_ip_hdrincl() {
%1 = alloca [2 x i32]
%2 = alloca i32
%3 = bitcast [2 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = load i32, i32* @PF_INET
%6 = load i32, i32* @SOCK_STREAM
%7 = tail call i32 @socket(i32 %5, i32 %6, i32 0)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = tail call i32 @err(i32 -1, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 0
store i32 -1, i32* %12
store i32 4, i32* %2
%13 = load i32, i32* @IPPROTO_IP
%14 = load i32, i32* @IP_HDRINCL
%15 = call i64 @getsockopt(i32 %7, i32 %13, i32 %14, i32* %12, i32* %2)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 @err(i32 -1, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %11
%20 = load i64, i64* @errno
%21 = load i64, i64* @ENOPROTOOPT
%22 = icmp eq i64 %20, %21
br i1 %22, label %27, label %23
23: ; preds = %19
%24 = trunc i64 %20 to i32
%25 = call i32 @strerror(i64 %20)
%26 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([82 x i8], [82 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
br label %27
27: ; preds = %23, %19
store i32 1, i32* %12
%28 = load i32, i32* @IPPROTO_IP
%29 = load i32, i32* @IP_HDRINCL
%30 = call i64 @setsockopt(i32 %7, i32 %28, i32 %29, i32* %12, i32 4)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = call i32 @err(i32 -1, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.3, i64 0, i64 0))
br label %34
34: ; preds = %32, %27
%35 = load i64, i64* @errno
%36 = load i64, i64* @ENOPROTOOPT
%37 = icmp eq i64 %35, %36
br i1 %37, label %42, label %38
38: ; preds = %34
%39 = trunc i64 %35 to i32
%40 = call i32 @strerror(i64 %35)
%41 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.4, i64 0, i64 0), i32 %39, i32 %40)
br label %42
42: ; preds = %38, %34
%43 = call i32 @close(i32 %7)
%44 = load i32, i32* @PF_INET
%45 = load i32, i32* @SOCK_DGRAM
%46 = call i32 @socket(i32 %44, i32 %45, i32 0)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %42
%49 = call i32 @err(i32 -1, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0))
br label %50
50: ; preds = %48, %42
store i32 -1, i32* %12
store i32 4, i32* %2
%51 = load i32, i32* @IPPROTO_IP
%52 = load i32, i32* @IP_HDRINCL
%53 = call i64 @getsockopt(i32 %46, i32 %51, i32 %52, i32* %12, i32* %2)
%54 = icmp eq i64 %53, 0
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 @err(i32 -1, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.6, i64 0, i64 0))
br label %57
57: ; preds = %55, %50
%58 = load i64, i64* @errno
%59 = load i64, i64* @ENOPROTOOPT
%60 = icmp eq i64 %58, %59
br i1 %60, label %65, label %61
61: ; preds = %57
%62 = trunc i64 %58 to i32
%63 = call i32 @strerror(i64 %58)
%64 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.7, i64 0, i64 0), i32 %62, i32 %63)
br label %65
65: ; preds = %61, %57
%66 = load i32, i32* @IPPROTO_IP
%67 = load i32, i32* @IP_HDRINCL
%68 = call i64 @setsockopt(i32 %46, i32 %66, i32 %67, i32* %12, i32 4)
%69 = icmp eq i64 %68, 0
br i1 %69, label %70, label %72
70: ; preds = %65
%71 = call i32 @err(i32 -1, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.8, i64 0, i64 0))
br label %72
72: ; preds = %70, %65
%73 = load i64, i64* @errno
%74 = load i64, i64* @ENOPROTOOPT
%75 = icmp eq i64 %73, %74
br i1 %75, label %80, label %76
76: ; preds = %72
%77 = trunc i64 %73 to i32
%78 = call i32 @strerror(i64 %73)
%79 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([83 x i8], [83 x i8]* @.str.9, i64 0, i64 0), i32 %77, i32 %78)
br label %80
80: ; preds = %76, %72
%81 = call i32 @close(i32 %46)
%82 = load i32, i32* @PF_INET
%83 = load i32, i32* @SOCK_RAW
%84 = call i32 @socket(i32 %82, i32 %83, i32 0)
%85 = call i32 (...) @geteuid()
%86 = icmp eq i32 %85, 0
%87 = icmp eq i32 %84, -1
br i1 %86, label %92, label %88
88: ; preds = %80
br i1 %87, label %159, label %89
89: ; preds = %88
%90 = call i32 (...) @geteuid()
%91 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.10, i64 0, i64 0), i32 %90)
br label %159
92: ; preds = %80
br i1 %87, label %93, label %95
93: ; preds = %92
%94 = call i32 @err(i32 -1, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0))
br label %95
95: ; preds = %93, %92
store i32 -1, i32* %12
%96 = getelementptr inbounds [2 x i32], [2 x i32]* %1, i64 0, i64 1
store i32 -1, i32* %96
store i32 8, i32* %2
%97 = load i32, i32* @IPPROTO_IP
%98 = load i32, i32* @IP_HDRINCL
%99 = call i64 @getsockopt(i32 %84, i32 %97, i32 %98, i32* %12, i32* %2)
%100 = icmp slt i64 %99, 0
br i1 %100, label %101, label %103
101: ; preds = %95
%102 = call i32 @err(i32 -1, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.12, i64 0, i64 0))
br label %103
103: ; preds = %101, %95
%104 = load i32, i32* %2
%105 = icmp eq i32 %104, 4
br i1 %105, label %108, label %106
106: ; preds = %103
%107 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.13, i64 0, i64 0), i32 %104)
br label %108
108: ; preds = %106, %103
%109 = load i32, i32* %12
%110 = icmp eq i32 %109, 0
br i1 %110, label %113, label %111
111: ; preds = %108
%112 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.14, i64 0, i64 0), i32 %109)
br label %113
113: ; preds = %111, %108
store i32 1, i32* %12
%114 = load i32, i32* @IPPROTO_IP
%115 = load i32, i32* @IP_HDRINCL
%116 = call i64 @setsockopt(i32 %84, i32 %114, i32 %115, i32* %12, i32 4)
%117 = icmp slt i64 %116, 0
br i1 %117, label %118, label %120
118: ; preds = %113
%119 = call i32 @err(i32 -1, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.15, i64 0, i64 0))
br label %120
120: ; preds = %118, %113
store i32 -1, i32* %12
store i32 -1, i32* %96
store i32 8, i32* %2
%121 = load i32, i32* @IPPROTO_IP
%122 = load i32, i32* @IP_HDRINCL
%123 = call i64 @getsockopt(i32 %84, i32 %121, i32 %122, i32* %12, i32* %2)
%124 = icmp slt i64 %123, 0
br i1 %124, label %125, label %127
125: ; preds = %120
%126 = call i32 @err(i32 -1, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.16, i64 0, i64 0))
br label %127
127: ; preds = %125, %120
%128 = load i32, i32* %12
%129 = icmp eq i32 %128, 0
br i1 %129, label %130, label %133
130: ; preds = %127
%131 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.17, i64 0, i64 0), i32 0)
%132 = load i32, i32* %12
br label %133
133: ; preds = %130, %127
%134 = phi i32 [ %132, %130 ], [ %128, %127 ]
%135 = icmp eq i32 %134, 8
br i1 %135, label %138, label %136
136: ; preds = %133
%137 = call i32 @warnx(i8* getelementptr inbounds ([93 x i8], [93 x i8]* @.str.18, i64 0, i64 0), i32 %134)
br label %138
138: ; preds = %136, %133
store i32 0, i32* %12
%139 = load i32, i32* @IPPROTO_IP
%140 = load i32, i32* @IP_HDRINCL
%141 = call i64 @setsockopt(i32 %84, i32 %139, i32 %140, i32* %12, i32 4)
%142 = icmp slt i64 %141, 0
br i1 %142, label %143, label %145
143: ; preds = %138
%144 = call i32 @err(i32 -1, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.19, i64 0, i64 0))
br label %145
145: ; preds = %143, %138
store i32 -1, i32* %12
store i32 -1, i32* %96
store i32 8, i32* %2
%146 = load i32, i32* @IPPROTO_IP
%147 = load i32, i32* @IP_HDRINCL
%148 = call i64 @getsockopt(i32 %84, i32 %146, i32 %147, i32* %12, i32* %2)
%149 = icmp slt i64 %148, 0
br i1 %149, label %150, label %152
150: ; preds = %145
%151 = call i32 @err(i32 -1, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.20, i64 0, i64 0))
br label %152
152: ; preds = %150, %145
%153 = load i32, i32* %12
%154 = icmp eq i32 %153, 0
br i1 %154, label %157, label %155
155: ; preds = %152
%156 = call i32 (i32, i8*, i32, ...) @errx(i32 -1, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.17, i64 0, i64 0), i32 %153)
br label %157
157: ; preds = %155, %152
%158 = call i32 @close(i32 %84)
br label %159
159: ; preds = %88, %89, %157
ret void
}