#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__ ENOSYS;
int /*<<< orphan*/ SYS__sysctl;
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[] = {99, 99};
  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};
  int err = syscall(SYS__sysctl, &scargs);
  if (err == -1 && errno == ENOSYS)
    printf("ENOSYS\n");
  printf("xyzzy\n");
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x8,-0x10(%rbp)
lea    0x2ee2(%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   1040 <memset@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    -0x60(%rbp),%rsi
call   1050 <syscall@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    11e5 <main+0xa5>
mov    0x2e12(%rip),%rax
mov    (%rax),%rax
mov    0x2e18(%rip),%rcx
cmp    (%rcx),%rax
jne    11e5 <main+0xa5>
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x58,%rsp
movq   $0x8,(%rsp)
lea    0x2ef5(%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    0x2e56(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1040 <syscall@plt>
cmp    $0xffffffff,%eax
jne    11ad <main+0x7d>
mov    0x2e46(%rip),%rax
mov    (%rax),%rax
mov    0x2e4c(%rip),%rcx
cmp    (%rcx),%rax
jne    11ad <main+0x7d>
lea    0xe5e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe4c(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1050 <exit@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 99, i32 99]
@SYS__sysctl = global i32 0
@errno = global i64 0
@ENOSYS = global i64 0
@.str = [8 x i8] c"ENOSYS\0A\00"
@.str.1 = [7 x i8] c"xyzzy\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca %struct.__sysctl_args
%4 = alloca i32
store i32 0, i32* %1
store i64 8, i64* %2
%5 = 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** %5
%6 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 1
store i32 2, i32* %6
%7 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 2
store i8* inttoptr (i64 -1 to i8*), i8** %7
%8 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 3
store i64* %2, i64** %8
%9 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 4
store i8* null, i8** %9
%10 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 5
store i64 0, i64* %10
%11 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i32 0, i32 6
%12 = bitcast [4 x i64]* %11 to i8*
%13 = load i32, i32* @SYS__sysctl
%14 = bitcast %struct.__sysctl_args* %3 to %struct.__sysctl_args.0*
%15 = call i32 @syscall(i32 %13, %struct.__sysctl_args.0* %14)
store i32 %15, i32* %4
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %24
18: ; preds = %0
%19 = load i64, i64* @errno
%20 = load i64, i64* @ENOSYS
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %18
%23 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %22, %18, %0
%25 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%26 = 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 99, i32 99]
@SYS__sysctl = global i32 0
@errno = global i64 0
@ENOSYS = global i64 0
@str = [6 x i8] c"xyzzy\00"
@str.2 = [7 x i8] c"ENOSYS\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 %21
15: ; preds = %0
%16 = load i64, i64* @errno
%17 = load i64, i64* @ENOSYS
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %15, %0
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%23 = call i32 @exit(i32 0)
unreachable
}