#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 /*<<< orphan*/ mib;

/* Variables and functions */
int CTL_NET;
int IPPROTO_IPV6;
int PF_INET6;
int sysctl(int *, int, int *, size_t *, int /*<<< orphan*/ *,
           int /*<<< orphan*/);
int inet6_sysctl(int code) {
  int mib[] = {CTL_NET, PF_INET6, IPPROTO_IPV6, 0};
  int val;
  size_t size;
  mib[3] = code;
  size = sizeof(val);
  if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), &val, &size, NULL, 0) == -1)
    return -1;
  return val;
}


x86 assembly (clang, -O0):
<inet6_sysctl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    0x2eb6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    0x2eba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
movq   $0x4,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
mov    $0x4,%esi
lea    -0x24(%rbp),%rdx
lea    -0x30(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%r8d
xor    %r9d,%r9d
call   1030 <sysctl@plt>
cmp    $0xffffffff,%eax
jne    1187 <inet6_sysctl+0x77>
movl   $0xffffffff,-0x4(%rbp)
jmp    118d <inet6_sysctl+0x7d>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet6_sysctl>:
sub    $0x28,%rsp
mov    0x2ebd(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2ec0(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
mov    %edi,0x1c(%rsp)
movq   $0x4,0x20(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rdx
lea    0x20(%rsp),%rcx
mov    $0x4,%esi
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1030 <sysctl@plt>
cmp    $0xffffffff,%eax
je     1170 <inet6_sysctl+0x60>
mov    0xc(%rsp),%eax
add    $0x28,%rsp
ret

LLVM IR (-O0):
@CTL_NET = global i32 0
@PF_INET6 = global i32 0
@IPPROTO_IPV6 = global i32 0
define i32 @inet6_sysctl(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [4 x i32]
%5 = alloca i32
%6 = alloca i64
store i32 %0, i32* %3
%7 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%8 = load i32, i32* @CTL_NET
store i32 %8, i32* %7
%9 = getelementptr inbounds i32, i32* %7, i64 1
%10 = load i32, i32* @PF_INET6
store i32 %10, i32* %9
%11 = getelementptr inbounds i32, i32* %9, i64 1
%12 = load i32, i32* @IPPROTO_IPV6
store i32 %12, i32* %11
%13 = getelementptr inbounds i32, i32* %11, i64 1
store i32 0, i32* %13
%14 = load i32, i32* %3
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 3
store i32 %14, i32* %15
store i64 4, i64* %6
%16 = getelementptr inbounds [4 x i32], [4 x i32]* %4, i64 0, i64 0
%17 = call i32 @sysctl(i32* %16, i32 4, i32* %5, i64* %6, i32* null, i32 0)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %1
store i32 -1, i32* %2
br label %22
20: ; preds = %1
%21 = load i32, i32* %5
store i32 %21, i32* %2
br label %22
22: ; preds = %20, %19
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@CTL_NET = global i32 0
@PF_INET6 = global i32 0
@IPPROTO_IPV6 = global i32 0
define i32 @inet6_sysctl(i32 %0) {
%2 = alloca [4 x i32]
%3 = alloca i32
%4 = alloca i64
%5 = bitcast [4 x i32]* %2 to i8*
%6 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 0
%7 = load i32, i32* @CTL_NET
store i32 %7, i32* %6
%8 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 1
%9 = load i32, i32* @PF_INET6
store i32 %9, i32* %8
%10 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 2
%11 = load i32, i32* @IPPROTO_IPV6
store i32 %11, i32* %10
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %2, i64 0, i64 3
%13 = bitcast i32* %3 to i8*
%14 = bitcast i64* %4 to i8*
store i32 %0, i32* %12
store i64 4, i64* %4
%15 = call i32 @sysctl(i32* %6, i32 4, i32* %3, i64* %4, i32* null, i32 0)
%16 = icmp eq i32 %15, -1
%17 = load i32, i32* %3
%18 = select i1 %16, i32 -1, i32 %17
ret i32 %18
}