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

/* Variables and functions */
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ err(int, char *, ...);
int /*<<< orphan*/ errx(int, char *, char const *, char *, ...);
scalar_t__ getsockopt(int, int /*<<< orphan*/, int, int *, int *);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int, int *, int);
void test_ip_boolean(int sock, const char *socktypename, int option,
                     char *optionname, int initial, int rootonly) {
  int newvalue, val[2];
  socklen_t len;
  if (initial == 0)
    newvalue = 0xff;
  else
    newvalue = 0;
  val[0] = -1;
  val[1] = -1;
  len = sizeof(val);
  if (getsockopt(sock, IPPROTO_IP, option, val, &len) < 0)
    err(-1, "test_ip_boolean: initial getsockopt()");
  if (len != sizeof(val[0]))
    errx(-1,
         "test_ip_boolean(%s, %s): initial getsockopt() "
         "returned %d bytes",
         socktypename, optionname, len);
  if (val[0] == -1)
    errx(-1,
         "test_ip_boolean(%s, %s): initial getsockopt() "
         "didn't return data",
         socktypename, optionname);
  if (val[0] != initial)
    errx(-1,
         "test_ip_boolean(%s, %s): initial getsockopt() "
         "returned %d (expected %d)",
         socktypename, optionname, val[0], initial);
  if (setsockopt(sock, IPPROTO_IP, option, &newvalue, sizeof(newvalue)) < 0)
    err(-1, "test_ip_boolean(%s, %s): setsockopt() to %d", socktypename,
        optionname, newvalue);
  val[0] = -1;
  val[1] = -1;
  len = sizeof(val);
  if (getsockopt(sock, IPPROTO_IP, option, val, &len) < 0)
    err(-1,
        "test_ip_boolean(%s, %s): getsockopt() after set to "
        "%d",
        socktypename, optionname, newvalue);
  if (len != sizeof(val[0]))
    errx(-1,
         "test_ip_boolean(%s, %s): getsockopt() after set "
         "to %d returned %d bytes",
         socktypename, optionname, newvalue, len);
  if (val[0] == -1)
    errx(-1,
         "test_ip_boolean(%s, %s): getsockopt() after set "
         "to %d didn't return data",
         socktypename, optionname, newvalue);
  if (val[0] != (newvalue ? 1 : 0))
    errx(-1,
         "test_ip_boolean(%s, %s): getsockopt() after set "
         "to %d returned %d",
         socktypename, optionname, newvalue, val[0]);
  newvalue = initial;
  if (setsockopt(sock, IPPROTO_IP, option, &newvalue, sizeof(newvalue)) < 0)
    err(-1, "test_ip_boolean(%s, %s): setsockopt() to reset", socktypename,
        optionname);
  val[0] = -1;
  val[1] = -1;
  len = sizeof(val);
  if (getsockopt(sock, IPPROTO_IP, option, val, &len) < 0)
    err(-1, "test_ip_boolean(%s, %s): getsockopt() after reset", socktypename,
        optionname);
  if (len != sizeof(val[0]))
    errx(-1,
         "test_ip_boolean(%s, %s): getsockopt() after reset "
         "returned %d bytes",
         socktypename, optionname, len);
  if (val[0] == -1)
    errx(-1,
         "test_ip_boolean(%s, %s): getsockopt() after reset "
         "didn't return data",
         socktypename, optionname);
  if (val[0] != newvalue)
    errx(-1,
         "test_ip_boolean(%s, %s): getsockopt() after reset "
         "returned %d",
         socktypename, optionname, newvalue);
}


x86 assembly (clang, -O0):
<test_ip_boolean>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    1174 <test_ip_boolean+0x34>
movl   $0xff,-0x2c(%rbp)
jmp    117b <test_ip_boolean+0x3b>
movl   $0x0,-0x2c(%rbp)
movl   $0xffffffff,-0x34(%rbp)
movl   $0xffffffff,-0x30(%rbp)
movl   $0x8,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    -0x34(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1050 <getsockopt@plt>
cmp    $0x0,%rax
jge    11c9 <test_ip_boolean+0x89>
mov    $0xffffffff,%edi
lea    0xe3e(%rip),%rsi
mov    $0x0,%al
call   1060 <err@plt>
movslq -0x38(%rbp),%rax
cmp    $0x4,%rax
je     11f6 <test_ip_boolean+0xb6>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x38(%rbp),%r8d
mov    $0xffffffff,%edi
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
cmpl   $0xffffffff,-0x34(%rbp)
jne    121b <test_ip_boolean+0xdb>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0xffffffff,%edi
lea    0xe52(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    -0x34(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     124a <test_ip_boolean+0x10a>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%r8d
mov    -0x24(%rbp),%r9d
mov    $0xffffffff,%edi
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    -0x4(%rbp),%edi
mov    0x2d94(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    -0x2c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1291 <test_ip_boolean+0x151>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    $0xffffffff,%edi
lea    0xe65(%rip),%rsi
mov    $0x0,%al
call   1060 <err@plt>
movl   $0xffffffff,-0x34(%rbp)
movl   $0xffffffff,-0x30(%rbp)
movl   $0x8,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2d38(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    -0x34(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1050 <getsockopt@plt>
cmp    $0x0,%rax
jge    12eb <test_ip_boolean+0x1ab>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    $0xffffffff,%edi
lea    0xe37(%rip),%rsi
mov    $0x0,%al
call   1060 <err@plt>
movslq -0x38(%rbp),%rax
cmp    $0x4,%rax
je     131c <test_ip_boolean+0x1dc>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    -0x38(%rbp),%r9d
mov    $0xffffffff,%edi
lea    0xe3c(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
cmpl   $0xffffffff,-0x34(%rbp)
jne    1345 <test_ip_boolean+0x205>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    $0xffffffff,%edi
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    -0x34(%rbp),%eax
mov    -0x2c(%rbp),%esi
xor    %ecx,%ecx
mov    $0x1,%edx
cmp    $0x0,%esi
cmovne %edx,%ecx
cmp    %ecx,%eax
je     1383 <test_ip_boolean+0x243>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    -0x34(%rbp),%r9d
mov    $0xffffffff,%edi
lea    0xe66(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2c55(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    -0x2c(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    13cc <test_ip_boolean+0x28c>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0xffffffff,%edi
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1060 <err@plt>
movl   $0xffffffff,-0x34(%rbp)
movl   $0xffffffff,-0x30(%rbp)
movl   $0x8,-0x38(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2bfd(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%edx
lea    -0x34(%rbp),%rcx
lea    -0x38(%rbp),%r8
call   1050 <getsockopt@plt>
cmp    $0x0,%rax
jge    1422 <test_ip_boolean+0x2e2>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0xffffffff,%edi
lea    0xe38(%rip),%rsi
mov    $0x0,%al
call   1060 <err@plt>
movslq -0x38(%rbp),%rax
cmp    $0x4,%rax
je     144f <test_ip_boolean+0x30f>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x38(%rbp),%r8d
mov    $0xffffffff,%edi
lea    0xe3d(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
cmpl   $0xffffffff,-0x34(%rbp)
jne    1474 <test_ip_boolean+0x334>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    $0xffffffff,%edi
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
mov    -0x34(%rbp),%eax
cmp    -0x2c(%rbp),%eax
je     149f <test_ip_boolean+0x35f>
mov    -0x10(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x2c(%rbp),%r8d
mov    $0xffffffff,%edi
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1040 <errx@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ip_boolean>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r12d
mov    %rcx,%r14
mov    %edx,%ebp
mov    %rsi,%r15
mov    %edi,%ebx
xor    %eax,%eax
test   %r8d,%r8d
mov    $0xff,%ecx
cmovne %eax,%ecx
mov    %ecx,0x8(%rsp)
movq   $0xffffffffffffffff,0x10(%rsp)
ff ff
movl   $0x8,0xc(%rsp)
mov    0x2e64(%rip),%r13
mov    0x0(%r13),%esi
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
call   1050 <getsockopt@plt>
test   %rax,%rax
jns    11af <test_ip_boolean+0x6f>
lea    0xe5d(%rip),%rsi
mov    $0xffffffff,%edi
xor    %eax,%eax
call   1060 <err@plt>
mov    0xc(%rsp),%r8d
cmp    $0x4,%r8d
je     11d3 <test_ip_boolean+0x93>
lea    0xe65(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <errx@plt>
mov    0x10(%rsp),%r8d
cmp    $0xffffffff,%r8d
je     1408 <test_ip_boolean+0x2c8>
cmp    %r12d,%r8d
je     1203 <test_ip_boolean+0xc3>
lea    0xeb9(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %r12d,%r9d
xor    %eax,%eax
call   1040 <errx@plt>
mov    0x0(%r13),%esi
lea    0x8(%rsp),%rcx
mov    %ebx,%edi
mov    %ebp,%edx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    123e <test_ip_boolean+0xfe>
mov    0x8(%rsp),%r8d
lea    0xec3(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <err@plt>
movq   $0xffffffffffffffff,0x10(%rsp)
ff ff
movl   $0x8,0xc(%rsp)
mov    0x0(%r13),%esi
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %ebx,%edi
mov    %ebp,%edx
call   1050 <getsockopt@plt>
test   %rax,%rax
jns    1289 <test_ip_boolean+0x149>
mov    0x8(%rsp),%r8d
lea    0xea4(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <err@plt>
mov    0xc(%rsp),%r9d
cmp    $0x4,%r9d
je     12b2 <test_ip_boolean+0x172>
mov    0x8(%rsp),%r8d
lea    0xeb1(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <errx@plt>
mov    0x10(%rsp),%r9d
cmp    $0xffffffff,%r9d
jne    12e0 <test_ip_boolean+0x1a0>
mov    0x8(%rsp),%r8d
lea    0xed0(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <errx@plt>
mov    0x10(%rsp),%r9d
mov    0x8(%rsp),%r8d
xor    %eax,%eax
test   %r8d,%r8d
setne  %al
cmp    %eax,%r9d
je     130b <test_ip_boolean+0x1cb>
lea    0xee9(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <errx@plt>
mov    %r12d,0x8(%rsp)
mov    0x0(%r13),%esi
lea    0x8(%rsp),%rcx
mov    %ebx,%edi
mov    %ebp,%edx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
jns    1346 <test_ip_boolean+0x206>
lea    0xef0(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <err@plt>
movq   $0xffffffffffffffff,0x10(%rsp)
ff ff
movl   $0x8,0xc(%rsp)
mov    0x0(%r13),%esi
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %ebx,%edi
mov    %ebp,%edx
call   1050 <getsockopt@plt>
test   %rax,%rax
jns    138c <test_ip_boolean+0x24c>
lea    0xed9(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <err@plt>
mov    0xc(%rsp),%r8d
cmp    $0x4,%r8d
je     13b0 <test_ip_boolean+0x270>
lea    0xee7(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <errx@plt>
mov    0x10(%rsp),%eax
cmp    $0xffffffff,%eax
jne    13d6 <test_ip_boolean+0x296>
lea    0xf09(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <errx@plt>
mov    0x10(%rsp),%eax
mov    0x8(%rsp),%r8d
cmp    %r8d,%eax
je     13f9 <test_ip_boolean+0x2b9>
lea    0xf27(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <errx@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc57(%rip),%rsi
mov    $0xffffffff,%edi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1040 <errx@plt>
mov    0x10(%rsp),%r8d
cmp    %r12d,%r8d
jne    11e7 <test_ip_boolean+0xa7>
jmp    1203 <test_ip_boolean+0xc3>

LLVM IR (-O0):
@IPPROTO_IP = global i32 0
@.str = [38 x i8] c"test_ip_boolean: initial getsockopt()\00"
@.str.1 = [64 x i8] c"test_ip_boolean(%s, %s): initial getsockopt() returned %d bytes\00"
@.str.2 = [65 x i8] c"test_ip_boolean(%s, %s): initial getsockopt() didn't return data\00"
@.str.3 = [72 x i8] c"test_ip_boolean(%s, %s): initial getsockopt() returned %d (expected %d)\00"
@.str.4 = [44 x i8] c"test_ip_boolean(%s, %s): setsockopt() to %d\00"
@.str.5 = [54 x i8] c"test_ip_boolean(%s, %s): getsockopt() after set to %d\00"
@.str.6 = [72 x i8] c"test_ip_boolean(%s, %s): getsockopt() after set to %d returned %d bytes\00"
@.str.7 = [73 x i8] c"test_ip_boolean(%s, %s): getsockopt() after set to %d didn't return data\00"
@.str.8 = [66 x i8] c"test_ip_boolean(%s, %s): getsockopt() after set to %d returned %d\00"
@.str.9 = [47 x i8] c"test_ip_boolean(%s, %s): setsockopt() to reset\00"
@.str.10 = [50 x i8] c"test_ip_boolean(%s, %s): getsockopt() after reset\00"
@.str.11 = [68 x i8] c"test_ip_boolean(%s, %s): getsockopt() after reset returned %d bytes\00"
@.str.12 = [69 x i8] c"test_ip_boolean(%s, %s): getsockopt() after reset didn't return data\00"
@.str.13 = [62 x i8] c"test_ip_boolean(%s, %s): getsockopt() after reset returned %d\00"
define void @test_ip_boolean(i32 %0, i8* %1, i32 %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca [2 x i32]
%15 = alloca i32
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i32 %5, i32* %12
%16 = load i32, i32* %11
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %6
store i32 255, i32* %13
br label %20
19: ; preds = %6
store i32 0, i32* %13
br label %20
20: ; preds = %19, %18
%21 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
store i32 -1, i32* %21
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
store i32 -1, i32* %22
store i32 8, i32* %15
%23 = load i32, i32* %7
%24 = load i32, i32* @IPPROTO_IP
%25 = load i32, i32* %9
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%27 = call i64 @getsockopt(i32 %23, i32 %24, i32 %25, i32* %26, i32* %15)
%28 = icmp slt i64 %27, 0
br i1 %28, label %29, label %31
29: ; preds = %20
%30 = call i32 (i32, i8*, ...) @err(i32 -1, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %20
%32 = load i32, i32* %15
%33 = sext i32 %32 to i64
%34 = icmp ne i64 %33, 4
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i8*, i8** %8
%37 = load i8*, i8** %10
%38 = load i32, i32* %15
%39 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0), i8* %36, i8* %37, i32 %38)
br label %40
40: ; preds = %35, %31
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%42 = load i32, i32* %41
%43 = icmp eq i32 %42, -1
br i1 %43, label %44, label %48
44: ; preds = %40
%45 = load i8*, i8** %8
%46 = load i8*, i8** %10
%47 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i8* %45, i8* %46)
br label %48
48: ; preds = %44, %40
%49 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%50 = load i32, i32* %49
%51 = load i32, i32* %11
%52 = icmp ne i32 %50, %51
br i1 %52, label %53, label %60
53: ; preds = %48
%54 = load i8*, i8** %8
%55 = load i8*, i8** %10
%56 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%57 = load i32, i32* %56
%58 = load i32, i32* %11
%59 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0), i8* %54, i8* %55, i32 %57, i32 %58)
br label %60
60: ; preds = %53, %48
%61 = load i32, i32* %7
%62 = load i32, i32* @IPPROTO_IP
%63 = load i32, i32* %9
%64 = call i64 @setsockopt(i32 %61, i32 %62, i32 %63, i32* %13, i32 4)
%65 = icmp slt i64 %64, 0
br i1 %65, label %66, label %71
66: ; preds = %60
%67 = load i8*, i8** %8
%68 = load i8*, i8** %10
%69 = load i32, i32* %13
%70 = call i32 (i32, i8*, ...) @err(i32 -1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %67, i8* %68, i32 %69)
br label %71
71: ; preds = %66, %60
%72 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
store i32 -1, i32* %72
%73 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
store i32 -1, i32* %73
store i32 8, i32* %15
%74 = load i32, i32* %7
%75 = load i32, i32* @IPPROTO_IP
%76 = load i32, i32* %9
%77 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%78 = call i64 @getsockopt(i32 %74, i32 %75, i32 %76, i32* %77, i32* %15)
%79 = icmp slt i64 %78, 0
br i1 %79, label %80, label %85
80: ; preds = %71
%81 = load i8*, i8** %8
%82 = load i8*, i8** %10
%83 = load i32, i32* %13
%84 = call i32 (i32, i8*, ...) @err(i32 -1, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i8* %81, i8* %82, i32 %83)
br label %85
85: ; preds = %80, %71
%86 = load i32, i32* %15
%87 = sext i32 %86 to i64
%88 = icmp ne i64 %87, 4
br i1 %88, label %89, label %95
89: ; preds = %85
%90 = load i8*, i8** %8
%91 = load i8*, i8** %10
%92 = load i32, i32* %13
%93 = load i32, i32* %15
%94 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.6, i64 0, i64 0), i8* %90, i8* %91, i32 %92, i32 %93)
br label %95
95: ; preds = %89, %85
%96 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%97 = load i32, i32* %96
%98 = icmp eq i32 %97, -1
br i1 %98, label %99, label %104
99: ; preds = %95
%100 = load i8*, i8** %8
%101 = load i8*, i8** %10
%102 = load i32, i32* %13
%103 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.7, i64 0, i64 0), i8* %100, i8* %101, i32 %102)
br label %104
104: ; preds = %99, %95
%105 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%106 = load i32, i32* %105
%107 = load i32, i32* %13
%108 = icmp ne i32 %107, 0
%109 = zext i1 %108 to i64
%110 = select i1 %108, i32 1, i32 0
%111 = icmp ne i32 %106, %110
br i1 %111, label %112, label %119
112: ; preds = %104
%113 = load i8*, i8** %8
%114 = load i8*, i8** %10
%115 = load i32, i32* %13
%116 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%117 = load i32, i32* %116
%118 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.8, i64 0, i64 0), i8* %113, i8* %114, i32 %115, i32 %117)
br label %119
119: ; preds = %112, %104
%120 = load i32, i32* %11
store i32 %120, i32* %13
%121 = load i32, i32* %7
%122 = load i32, i32* @IPPROTO_IP
%123 = load i32, i32* %9
%124 = call i64 @setsockopt(i32 %121, i32 %122, i32 %123, i32* %13, i32 4)
%125 = icmp slt i64 %124, 0
br i1 %125, label %126, label %130
126: ; preds = %119
%127 = load i8*, i8** %8
%128 = load i8*, i8** %10
%129 = call i32 (i32, i8*, ...) @err(i32 -1, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.9, i64 0, i64 0), i8* %127, i8* %128)
br label %130
130: ; preds = %126, %119
%131 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
store i32 -1, i32* %131
%132 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 1
store i32 -1, i32* %132
store i32 8, i32* %15
%133 = load i32, i32* %7
%134 = load i32, i32* @IPPROTO_IP
%135 = load i32, i32* %9
%136 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%137 = call i64 @getsockopt(i32 %133, i32 %134, i32 %135, i32* %136, i32* %15)
%138 = icmp slt i64 %137, 0
br i1 %138, label %139, label %143
139: ; preds = %130
%140 = load i8*, i8** %8
%141 = load i8*, i8** %10
%142 = call i32 (i32, i8*, ...) @err(i32 -1, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0), i8* %140, i8* %141)
br label %143
143: ; preds = %139, %130
%144 = load i32, i32* %15
%145 = sext i32 %144 to i64
%146 = icmp ne i64 %145, 4
br i1 %146, label %147, label %152
147: ; preds = %143
%148 = load i8*, i8** %8
%149 = load i8*, i8** %10
%150 = load i32, i32* %15
%151 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.11, i64 0, i64 0), i8* %148, i8* %149, i32 %150)
br label %152
152: ; preds = %147, %143
%153 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%154 = load i32, i32* %153
%155 = icmp eq i32 %154, -1
br i1 %155, label %156, label %160
156: ; preds = %152
%157 = load i8*, i8** %8
%158 = load i8*, i8** %10
%159 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.12, i64 0, i64 0), i8* %157, i8* %158)
br label %160
160: ; preds = %156, %152
%161 = getelementptr inbounds [2 x i32], [2 x i32]* %14, i64 0, i64 0
%162 = load i32, i32* %161
%163 = load i32, i32* %13
%164 = icmp ne i32 %162, %163
br i1 %164, label %165, label %170
165: ; preds = %160
%166 = load i8*, i8** %8
%167 = load i8*, i8** %10
%168 = load i32, i32* %13
%169 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.13, i64 0, i64 0), i8* %166, i8* %167, i32 %168)
br label %170
170: ; preds = %165, %160
ret void
}

LLVM IR (-O2):
@IPPROTO_IP = global i32 0
@.str = [38 x i8] c"test_ip_boolean: initial getsockopt()\00"
@.str.1 = [64 x i8] c"test_ip_boolean(%s, %s): initial getsockopt() returned %d bytes\00"
@.str.2 = [65 x i8] c"test_ip_boolean(%s, %s): initial getsockopt() didn't return data\00"
@.str.3 = [72 x i8] c"test_ip_boolean(%s, %s): initial getsockopt() returned %d (expected %d)\00"
@.str.4 = [44 x i8] c"test_ip_boolean(%s, %s): setsockopt() to %d\00"
@.str.5 = [54 x i8] c"test_ip_boolean(%s, %s): getsockopt() after set to %d\00"
@.str.6 = [72 x i8] c"test_ip_boolean(%s, %s): getsockopt() after set to %d returned %d bytes\00"
@.str.7 = [73 x i8] c"test_ip_boolean(%s, %s): getsockopt() after set to %d didn't return data\00"
@.str.8 = [66 x i8] c"test_ip_boolean(%s, %s): getsockopt() after set to %d returned %d\00"
@.str.9 = [47 x i8] c"test_ip_boolean(%s, %s): setsockopt() to reset\00"
@.str.10 = [50 x i8] c"test_ip_boolean(%s, %s): getsockopt() after reset\00"
@.str.11 = [68 x i8] c"test_ip_boolean(%s, %s): getsockopt() after reset returned %d bytes\00"
@.str.12 = [69 x i8] c"test_ip_boolean(%s, %s): getsockopt() after reset didn't return data\00"
@.str.13 = [62 x i8] c"test_ip_boolean(%s, %s): getsockopt() after reset returned %d\00"
define void @test_ip_boolean(i32 %0, i8* %1, i32 %2, i8* %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca [2 x i32]
%9 = alloca i32
%10 = bitcast i32* %7 to i8*
%11 = bitcast [2 x i32]* %8 to i8*
%12 = bitcast i32* %9 to i8*
%13 = icmp eq i32 %4, 0
%14 = select i1 %13, i32 255, i32 0
store i32 %14, i32* %7
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 0
store i32 -1, i32* %15
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %8, i64 0, i64 1
store i32 -1, i32* %16
store i32 8, i32* %9
%17 = load i32, i32* @IPPROTO_IP
%18 = call i64 @getsockopt(i32 %0, i32 %17, i32 %2, i32* %15, i32* %9)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %6
%21 = call i32 (i32, i8*, ...) @err(i32 -1, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %22
22: ; preds = %20, %6
%23 = load i32, i32* %9
%24 = icmp eq i32 %23, 4
br i1 %24, label %27, label %25
25: ; preds = %22
%26 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %3, i32 %23)
br label %27
27: ; preds = %25, %22
%28 = load i32, i32* %15
%29 = icmp eq i32 %28, -1
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.2, i64 0, i64 0), i8* %1, i8* %3)
%32 = load i32, i32* %15
br label %33
33: ; preds = %30, %27
%34 = phi i32 [ %32, %30 ], [ %28, %27 ]
%35 = icmp eq i32 %34, %4
br i1 %35, label %38, label %36
36: ; preds = %33
%37 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.3, i64 0, i64 0), i8* %1, i8* %3, i32 %34, i32 %4)
br label %38
38: ; preds = %36, %33
%39 = load i32, i32* @IPPROTO_IP
%40 = call i64 @setsockopt(i32 %0, i32 %39, i32 %2, i32* %7, i32 4)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i32, i32* %7
%44 = call i32 (i32, i8*, ...) @err(i32 -1, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.4, i64 0, i64 0), i8* %1, i8* %3, i32 %43)
br label %45
45: ; preds = %42, %38
store i32 -1, i32* %15
store i32 -1, i32* %16
store i32 8, i32* %9
%46 = load i32, i32* @IPPROTO_IP
%47 = call i64 @getsockopt(i32 %0, i32 %46, i32 %2, i32* %15, i32* %9)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %45
%50 = load i32, i32* %7
%51 = call i32 (i32, i8*, ...) @err(i32 -1, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.5, i64 0, i64 0), i8* %1, i8* %3, i32 %50)
br label %52
52: ; preds = %49, %45
%53 = load i32, i32* %9
%54 = icmp eq i32 %53, 4
br i1 %54, label %58, label %55
55: ; preds = %52
%56 = load i32, i32* %7
%57 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([72 x i8], [72 x i8]* @.str.6, i64 0, i64 0), i8* %1, i8* %3, i32 %56, i32 %53)
br label %58
58: ; preds = %55, %52
%59 = load i32, i32* %15
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = load i32, i32* %7
%63 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.7, i64 0, i64 0), i8* %1, i8* %3, i32 %62)
%64 = load i32, i32* %15
br label %65
65: ; preds = %61, %58
%66 = phi i32 [ %64, %61 ], [ %59, %58 ]
%67 = load i32, i32* %7
%68 = icmp ne i32 %67, 0
%69 = zext i1 %68 to i32
%70 = icmp eq i32 %66, %69
br i1 %70, label %73, label %71
71: ; preds = %65
%72 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.8, i64 0, i64 0), i8* %1, i8* %3, i32 %67, i32 %66)
br label %73
73: ; preds = %71, %65
store i32 %4, i32* %7
%74 = load i32, i32* @IPPROTO_IP
%75 = call i64 @setsockopt(i32 %0, i32 %74, i32 %2, i32* %7, i32 4)
%76 = icmp slt i64 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %73
%78 = call i32 (i32, i8*, ...) @err(i32 -1, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.9, i64 0, i64 0), i8* %1, i8* %3)
br label %79
79: ; preds = %77, %73
store i32 -1, i32* %15
store i32 -1, i32* %16
store i32 8, i32* %9
%80 = load i32, i32* @IPPROTO_IP
%81 = call i64 @getsockopt(i32 %0, i32 %80, i32 %2, i32* %15, i32* %9)
%82 = icmp slt i64 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %79
%84 = call i32 (i32, i8*, ...) @err(i32 -1, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0), i8* %1, i8* %3)
br label %85
85: ; preds = %83, %79
%86 = load i32, i32* %9
%87 = icmp eq i32 %86, 4
br i1 %87, label %90, label %88
88: ; preds = %85
%89 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([68 x i8], [68 x i8]* @.str.11, i64 0, i64 0), i8* %1, i8* %3, i32 %86)
br label %90
90: ; preds = %88, %85
%91 = load i32, i32* %15
%92 = icmp eq i32 %91, -1
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.12, i64 0, i64 0), i8* %1, i8* %3)
%95 = load i32, i32* %15
br label %96
96: ; preds = %93, %90
%97 = phi i32 [ %95, %93 ], [ %91, %90 ]
%98 = load i32, i32* %7
%99 = icmp eq i32 %97, %98
br i1 %99, label %102, label %100
100: ; preds = %96
%101 = call i32 (i32, i8*, i8*, i8*, ...) @errx(i32 -1, i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.13, i64 0, i64 0), i8* %1, i8* %3, i32 %98)
br label %102
102: ; preds = %100, %96
ret void
}