#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 */
struct __sysctl_args {
  int *name;
  long nlen;
  void *oldval;
};

/* Variables and functions */
int /*<<< orphan*/ SYS__sysctl;
int /*<<< orphan*/ memset(struct __sysctl_args *, int /*<<< orphan*/, int);
int syscall(int /*<<< orphan*/, struct __sysctl_args *);
int sysextend(long func, void *args) {
  struct __sysctl_args wrap;
  memset(&wrap, 0, sizeof(struct __sysctl_args));
  wrap.name = (int *)1;
  wrap.nlen = func;
  wrap.oldval = args;
  return syscall(SYS__sysctl, &wrap);
}


x86 assembly (clang, -O0):
<sysextend>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x28(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
mov    $0x1,%eax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1040 <syscall@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sysextend>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0x8(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1030 <memset@plt>
movq   $0x1,0x8(%rsp)
mov    %rbx,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    0x2e83(%rip),%rax
mov    (%rax),%edi
mov    %r15,%rsi
call   1040 <syscall@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.__sysctl_args = type { i32*, i64, i8* }
@SYS__sysctl = global i32 0
define i32 @sysextend(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca %struct.__sysctl_args
store i64 %0, i64* %3
store i8* %1, i8** %4
%6 = call i32 @memset(%struct.__sysctl_args* %5, i32 0, i32 24)
%7 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %5, i32 0, i32 0
store i32* inttoptr (i64 1 to i32*), i32** %7
%8 = load i64, i64* %3
%9 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %5, i32 0, i32 1
store i64 %8, i64* %9
%10 = load i8*, i8** %4
%11 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %5, i32 0, i32 2
store i8* %10, i8** %11
%12 = load i32, i32* @SYS__sysctl
%13 = call i32 @syscall(i32 %12, %struct.__sysctl_args* %5)
ret i32 %13
}

LLVM IR (-O2):
%struct.__sysctl_args = type { i32*, i64, i8* }
@SYS__sysctl = global i32 0
define i32 @sysextend(i64 %0, i8* %1) {
%3 = alloca %struct.__sysctl_args
%4 = bitcast %struct.__sysctl_args* %3 to i8*
%5 = call i32 @memset(%struct.__sysctl_args* %3, i32 0, i32 24)
%6 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i64 0, i32 0
store i32* inttoptr (i64 1 to i32*), i32** %6
%7 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i64 0, i32 1
store i64 %0, i64* %7
%8 = getelementptr inbounds %struct.__sysctl_args, %struct.__sysctl_args* %3, i64 0, i32 2
store i8* %1, i8** %8
%9 = load i32, i32* @SYS__sysctl
%10 = call i32 @syscall(i32 %9, %struct.__sysctl_args* %3)
ret i32 %10
}