#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 __sysctl_args TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ sysctl_args;
struct __sysctl_args {
  int *name;
  int nlen;
  void *oldval;
  size_t *oldlenp;
  void *newval;
  size_t newlen;
  unsigned long *__unused;
};

/* Variables and functions */
scalar_t__ EFAULT;
int /*<<< orphan*/ SYS__sysctl;
int /*<<< orphan*/ abort();
scalar_t__ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int syscall(int /*<<< orphan*/, TYPE_1__ *);
int main(void) {
  static int sysctl_args[] = {1, 4};
  size_t x = 8;
  struct __sysctl_args {
    int *name;
    int nlen;
    void *oldval;
    size_t *oldlenp;
    void *newval;
    size_t newlen;
    unsigned long __unused[4];
  } scargs = {sysctl_args, sizeof(sysctl_args) / sizeof(sysctl_args[0]),
              (void *)-1,  &x,
              NULL,        0};
  if (syscall(SYS__sysctl, &scargs) != -1 || errno != EFAULT)
    abort();
  printf("pass\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x8,-0x10(%rbp)
lea    0x2eda(%rip),%rax
mov    %rax,-0x60(%rbp)
movl   $0x2,-0x58(%rbp)
mov    $0xffffffffffffffff,%rax
mov    %rax,-0x50(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
movq   $0x0,-0x40(%rbp)
movq   $0x0,-0x38(%rbp)
lea    -0x60(%rbp),%rdi
add    $0x30,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
call   1060 <syscall@plt>
cmp    $0xffffffff,%eax
jne    11e5 <main+0x95>
mov    0x2e06(%rip),%rax
mov    (%rax),%rax
mov    0x2e1c(%rip),%rcx
cmp    (%rcx),%rax
je     11ec <main+0x9c>
mov    $0x0,%al
call   1030 <abort@plt>
lea    0xe0d(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
movq   $0x8,(%rsp)
lea    0x2eed(%rip),%rax
mov    %rax,0x8(%rsp)
movl   $0x2,0x10(%rsp)
movq   $0xffffffffffffffff,0x18(%rsp)
ff ff
mov    %rsp,%rax
mov    %rax,0x20(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x28(%rsp)
movups %xmm0,0x38(%rsp)
movups %xmm0,0x48(%rsp)
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1050 <syscall@plt>
cmp    $0xffffffff,%eax
jne    11c4 <main+0x84>
mov    0x2e36(%rip),%rax
mov    (%rax),%rax
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%rax
jne    11c4 <main+0x84>
lea    0xe48(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
%struct.__sysctl_args = type { i32*, i32, i8*, i64*, i8*, i64, [4 x i64] }
%struct.__sysctl_args.0 = type { i32*, i32, i8*, i64*, i8*, i64, i64* }
@main.sysctl_args = internal global [2 x i32] [i32 1, i32 4]
@SYS__sysctl = global i32 0
@errno = global i64 0
@EFAULT = global i64 0
@.str = [6 x i8] c"pass\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca %struct.__sysctl_args
store i32 0, i32* %1
store i64 8, i64* %2
%4 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 0
store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.sysctl_args, i64 0, i64 0), i32** %4
%5 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 1
store i32 2, i32* %5
%6 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 2
store i8* inttoptr (i64 -1 to i8*), i8** %6
%7 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 3
store i64* %2, i64** %7
%8 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 4
store i8* null, i8** %8
%9 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 5
store i64 0, i64* %9
%10 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 6
%11 = bitcast [4 x i64]* %10 to i8*
%12 = load i32, i32* @SYS__sysctl
%13 = bitcast %struct.__sysctl_args* %3 to %struct.__sysctl_args.0*
%14 = call i32 @syscall(i32 %12, %struct.__sysctl_args.0* %13)
%15 = icmp ne i32 %14, -1
br i1 %15, label %20, label %16
16: ; preds = %0
%17 = load i64, i64* @errno
%18 = load i64, i64* @EFAULT
%19 = icmp ne i64 %17, %18
br i1 %19, label %20, label %22
20: ; preds = %16, %0
%21 = call i32 (...) @abort()
unreachable
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%24 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.__sysctl_args = type { i32*, i32, i8*, i64*, i8*, i64, [4 x i64] }
%struct.__sysctl_args.0 = type { i32*, i32, i8*, i64*, i8*, i64, i64* }
@main.sysctl_args = internal global [2 x i32] [i32 1, i32 4]
@SYS__sysctl = global i32 0
@errno = global i64 0
@EFAULT = global i64 0
@str = [5 x i8] c"pass\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca %struct.__sysctl_args
%3 = bitcast i64* %1 to i8*
store i64 8, i64* %1
%4 = bitcast %struct.__sysctl_args* %2 to i8*
%5 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %2, i64 0, i32 0
store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @main.sysctl_args, i64 0, i64 0), i32** %5
%6 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %2, i64 0, i32 1
store i32 2, i32* %6
%7 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %2, i64 0, i32 2
store i8* inttoptr (i64 -1 to i8*), i8** %7
%8 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %2, i64 0, i32 3
store i64* %1, i64** %8
%9 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %2, i64 0, i32 4
%10 = bitcast i8** %9 to i8*
%11 = load i32, i32* @SYS__sysctl
%12 = bitcast %struct.__sysctl_args* %2 to %struct.__sysctl_args.0*
%13 = call i32 @syscall(i32 %11, %struct.__sysctl_args.0* %12)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %19
15: ; preds = %0
%16 = load i64, i64* @errno
%17 = load i64, i64* @EFAULT
%18 = icmp eq i64 %16, %17
br i1 %18, label %21, label %19
19: ; preds = %15, %0
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %15
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%23 = call i32 @exit(i32 0)
unreachable
}