#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 /*<<< orphan*/ strlen(char const *);
int sysctl(int *, int, int *, size_t *, char const *, int /*<<< orphan*/);
int sysctlnametomib(const char *name, int *mibp, size_t *sizep) {
  int oid[2];
  int error;
  oid[0] = 0;
  oid[1] = 3;
  *sizep *= sizeof(int);
  error = sysctl(oid, 2, mibp, sizep, name, strlen(name));
  *sizep /= sizeof(int);
  return (error);
}


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)
movl   $0x0,-0x20(%rbp)
movl   $0x3,-0x1c(%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):
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 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
store i32 0, i32* %9
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
store i32 3, i32* %10
%11 = load i64*, i64** %6
%12 = load i64, i64* %11
%13 = mul i64 %12, 4
store i64 %13, i64* %11
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%15 = load i32*, i32** %5
%16 = load i64*, i64** %6
%17 = load i8*, i8** %4
%18 = load i8*, i8** %4
%19 = call i32 @strlen(i8* %18)
%20 = call i32 @sysctl(i32* %14, i32 2, i32* %15, i64* %16, i8* %17, i32 %19)
store i32 %20, i32* %8
%21 = load i64*, i64** %6
%22 = load i64, i64* %21
%23 = udiv i64 %22, 4
store i64 %23, i64* %21
%24 = load i32, i32* %8
ret i32 %24
}

LLVM IR (-O2):
define i32 @sysctlnametomib(i8* %0, i32* %1, i64* %2) {
%4 = alloca [2 x i32]
%5 = bitcast [2 x i32]* %4 to i8*
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
store i32 0, i32* %6
%7 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
store i32 3, i32* %7
%8 = load i64, i64* %2
%9 = shl i64 %8, 2
store i64 %9, i64* %2
%10 = tail call i32 @strlen(i8* %0)
%11 = call i32 @sysctl(i32* %6, i32 2, i32* %1, i64* %2, i8* %0, i32 %10)
%12 = load i64, i64* %2
%13 = lshr i64 %12, 2
store i64 %13, i64* %2
ret i32 %11
}