#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 */

/* Variables and functions */
int __sysctl(int *, int, int *, size_t *, void *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
int __sysctlnametomib(const char *name, int *mibp, size_t *sizep) {
  int name2oid_request[2] = {0, 3};
  int retval;
  *sizep *= sizeof(int);
  retval =
      __sysctl(name2oid_request, 2, mibp, sizep, (void *)name, strlen(name));
  *sizep /= sizeof(int);
  return retval;
}


x86 assembly (clang, -O0):
<__sysctlnametomib>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0xec5(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
shl    $0x2,%rcx
mov    %rcx,(%rax)
lea    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x30(%rbp),%r8
mov    %eax,%r9d
mov    $0x2,%esi
call   1040 <__sysctl@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
shr    $0x2,%rcx
mov    %rcx,(%rax)
mov    -0x24(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__sysctlnametomib>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
movabs $0x300000000,%rax
mov    %rax,0x8(%rsp)
shlq   $0x2,(%rdx)
call   1030 <strlen@plt>
lea    0x8(%rsp),%rdi
mov    $0x2,%esi
mov    %r14,%rdx
mov    %rbx,%rcx
mov    %r15,%r8
mov    %eax,%r9d
call   1040 <__sysctl@plt>
shrq   $0x2,(%rbx)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.__sysctlnametomib.name2oid_request = [2 x i32] [i32 0, i32 3]
define i32 @__sysctlnametomib(i8* %0, i32* %1, i64* %2) {
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i64*
%7 = alloca [2 x i32]
%8 = alloca i32
store i8* %0, i8** %4
store i32* %1, i32** %5
store i64* %2, i64** %6
%9 = bitcast [2 x i32]* %7 to i8*
%10 = load i64*, i64** %6
%11 = load i64, i64* %10
%12 = mul i64 %11, 4
store i64 %12, i64* %10
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%14 = load i32*, i32** %5
%15 = load i64*, i64** %6
%16 = load i8*, i8** %4
%17 = load i8*, i8** %4
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @__sysctl(i32* %13, i32 2, i32* %14, i64* %15, i8* %16, i32 %18)
store i32 %19, i32* %8
%20 = load i64*, i64** %6
%21 = load i64, i64* %20
%22 = udiv i64 %21, 4
store i64 %22, i64* %20
%23 = load i32, i32* %8
ret i32 %23
}

LLVM IR (-O2):
define i32 @__sysctlnametomib(i8* %0, i32* %1, i64* %2) {
%4 = alloca i64
%5 = bitcast i64* %4 to i8*
store i64 12884901888, i64* %4
%6 = load i64, i64* %2
%7 = shl i64 %6, 2
store i64 %7, i64* %2
%8 = bitcast i64* %4 to i32*
%9 = tail call i32 @strlen(i8* %0)
%10 = call i32 @__sysctl(i32* %8, i32 2, i32* %1, i64* %2, i8* %0, i32 %9)
%11 = load i64, i64* %2
%12 = lshr i64 %11, 2
store i64 %12, i64* %2
ret i32 %10
}