#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*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
int /*<<< orphan*/ close(int);
long *mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int,
           int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/, int /*<<< orphan*/);
long *meter(int nchildren) {
  int fd;
  long *ptr;
  fd = open("/dev/zero", O_RDWR, 0);
  ptr = mmap(0, nchildren * sizeof(long), PROT_READ | PROT_WRITE, MAP_SHARED,
             fd, 0);
  close(fd);
  return ptr;
}


x86 assembly (clang, -O0):
<meter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%esi
lea    0xeb5(%rip),%rdi
xor    %edx,%edx
call   1050 <open@plt>
mov    %eax,-0x8(%rbp)
movslq -0x4(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
mov    0x2e92(%rip),%rax
mov    (%rax),%edx
mov    0x2e59(%rip),%rax
or     (%rax),%edx
mov    0x2e70(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%r8d
xor    %r9d,%r9d
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <close@plt>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<meter>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
lea    0xebb(%rip),%rdi
xor    %edx,%edx
call   1050 <open@plt>
mov    %eax,%ebp
shl    $0x3,%ebx
mov    0x2ea0(%rip),%rax
mov    0x2e69(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
mov    0x2e7e(%rip),%rax
mov    (%rax),%ecx
xor    %edi,%edi
mov    %ebx,%esi
mov    %ebp,%r8d
xor    %r9d,%r9d
call   1030 <mmap@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1040 <close@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"/dev/zero\00"
@O_RDWR = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define i64* @meter(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64*
store i32 %0, i32* %2
%5 = load i32, i32* @O_RDWR
%6 = call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %5, i32 0)
store i32 %6, i32* %3
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = mul i64 %8, 8
%10 = trunc i64 %9 to i32
%11 = load i32, i32* @PROT_READ
%12 = load i32, i32* @PROT_WRITE
%13 = or i32 %11, %12
%14 = load i32, i32* @MAP_SHARED
%15 = load i32, i32* %3
%16 = call i64* @mmap(i32 0, i32 %10, i32 %13, i32 %14, i32 %15, i32 0)
store i64* %16, i64** %4
%17 = load i32, i32* %3
%18 = call i32 @close(i32 %17)
%19 = load i64*, i64** %4
ret i64* %19
}

LLVM IR (-O2):
@.str = [10 x i8] c"/dev/zero\00"
@O_RDWR = global i32 0
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
define i64* @meter(i32 %0) {
%2 = load i32, i32* @O_RDWR
%3 = tail call i32 @open(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %2, i32 0)
%4 = shl i32 %0, 3
%5 = load i32, i32* @PROT_READ
%6 = load i32, i32* @PROT_WRITE
%7 = or i32 %6, %5
%8 = load i32, i32* @MAP_SHARED
%9 = tail call i64* @mmap(i32 0, i32 %4, i32 %7, i32 %8, i32 %3, i32 0)
%10 = tail call i32 @close(i32 %3)
ret i64* %9
}