#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 MAP_HUGETLB;
int /*<<< orphan*/ mmap_chunks_higher(int, int);
int /*<<< orphan*/ mmap_chunks_lower(int, int);
int /*<<< orphan*/ printf(char *);
void mixed_position_16M() {
  printf("Allocating 64k pages < 128TB \n");
  mmap_chunks_lower(4000, 0);
  printf("Allocating 16M chunks < 128TB \n");
  mmap_chunks_lower(32, MAP_HUGETLB);
  printf("Allocating 64k pages < 128TB \n");
  mmap_chunks_lower(4000, 0);
  printf("Allocating 16M chunks < 128TB \n");
  mmap_chunks_lower(32, MAP_HUGETLB);
  printf("Allocating 16G chunks < 128TB \n");
  mmap_chunks_lower(1, (MAP_HUGETLB | (34 << 26)));
  printf("Allocating 64k pages > 128TB \n");
  mmap_chunks_higher(12192, 0);
  printf("Allocating 16M chunks > 128TB \n");
  mmap_chunks_higher(32, MAP_HUGETLB);
  printf("Allocating 64k pages > 128TB \n");
  mmap_chunks_higher(12192, 0);
  printf("Allocating 16M chunks > 128TB \n");
  mmap_chunks_higher(32, MAP_HUGETLB);
  printf("Allocating 16G chunks > 128TB \n");
  mmap_chunks_higher(1, (MAP_HUGETLB | (34 << 26)));
}


x86 assembly (clang, -O0):
<mixed_position_16M>:
push   %rbp
mov    %rsp,%rbp
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
mov    $0xfa0,%edi
xor    %esi,%esi
call   1050 <mmap_chunks_lower@plt>
lea    0xecc(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1050 <mmap_chunks_lower@plt>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    $0xfa0,%edi
xor    %esi,%esi
call   1050 <mmap_chunks_lower@plt>
lea    0xe95(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1050 <mmap_chunks_lower@plt>
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%esi
or     $0x88000000,%esi
mov    $0x1,%edi
call   1050 <mmap_chunks_lower@plt>
lea    0xe91(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2fa0,%edi
xor    %esi,%esi
call   1040 <mmap_chunks_higher@plt>
lea    0xe98(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1040 <mmap_chunks_higher@plt>
lea    0xe5a(%rip),%rdi
call   1030 <printf@plt>
mov    $0x2fa0,%edi
xor    %esi,%esi
call   1040 <mmap_chunks_higher@plt>
lea    0xe61(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1040 <mmap_chunks_higher@plt>
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%esi
or     $0x88000000,%esi
mov    $0x1,%edi
call   1040 <mmap_chunks_higher@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<mixed_position_16M>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xfa0,%edi
xor    %esi,%esi
call   1050 <mmap_chunks_lower@plt>
lea    0xec4(%rip),%rbx
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    0x2e87(%rip),%r12
mov    (%r12),%esi
mov    $0x20,%edi
call   1050 <mmap_chunks_lower@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0xfa0,%edi
xor    %esi,%esi
call   1050 <mmap_chunks_lower@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    (%r12),%esi
mov    $0x20,%edi
call   1050 <mmap_chunks_lower@plt>
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
mov    $0x88000000,%ebx
mov    (%r12),%esi
or     %ebx,%esi
mov    $0x1,%edi
call   1050 <mmap_chunks_lower@plt>
lea    0xe93(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x2fa0,%edi
xor    %esi,%esi
call   1040 <mmap_chunks_higher@plt>
lea    0xe96(%rip),%r15
mov    %r15,%rdi
call   1030 <puts@plt>
mov    (%r12),%esi
mov    $0x20,%edi
call   1040 <mmap_chunks_higher@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    $0x2fa0,%edi
xor    %esi,%esi
call   1040 <mmap_chunks_higher@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    (%r12),%esi
mov    $0x20,%edi
call   1040 <mmap_chunks_higher@plt>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
or     (%r12),%ebx
mov    $0x1,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <mmap_chunks_higher@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"Allocating 64k pages < 128TB \0A\00"
@.str.1 = [32 x i8] c"Allocating 16M chunks < 128TB \0A\00"
@MAP_HUGETLB = global i32 0
@.str.2 = [32 x i8] c"Allocating 16G chunks < 128TB \0A\00"
@.str.3 = [31 x i8] c"Allocating 64k pages > 128TB \0A\00"
@.str.4 = [32 x i8] c"Allocating 16M chunks > 128TB \0A\00"
@.str.5 = [32 x i8] c"Allocating 16G chunks > 128TB \0A\00"
define void @mixed_position_16M() {
%1 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%2 = call i32 @mmap_chunks_lower(i32 4000, i32 0)
%3 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%4 = load i32, i32* @MAP_HUGETLB
%5 = call i32 @mmap_chunks_lower(i32 32, i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @mmap_chunks_lower(i32 4000, i32 0)
%8 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%9 = load i32, i32* @MAP_HUGETLB
%10 = call i32 @mmap_chunks_lower(i32 32, i32 %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%12 = load i32, i32* @MAP_HUGETLB
%13 = or i32 %12, -2013265920
%14 = call i32 @mmap_chunks_lower(i32 1, i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @mmap_chunks_higher(i32 12192, i32 0)
%17 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%18 = load i32, i32* @MAP_HUGETLB
%19 = call i32 @mmap_chunks_higher(i32 32, i32 %18)
%20 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%21 = call i32 @mmap_chunks_higher(i32 12192, i32 0)
%22 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%23 = load i32, i32* @MAP_HUGETLB
%24 = call i32 @mmap_chunks_higher(i32 32, i32 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%26 = load i32, i32* @MAP_HUGETLB
%27 = or i32 %26, -2013265920
%28 = call i32 @mmap_chunks_higher(i32 1, i32 %27)
ret void
}

LLVM IR (-O2):
@MAP_HUGETLB = global i32 0
@str.7 = [30 x i8] c"Allocating 64k pages < 128TB \00"
@str.8 = [31 x i8] c"Allocating 16M chunks < 128TB \00"
@str.9 = [31 x i8] c"Allocating 16G chunks < 128TB \00"
@str.12 = [30 x i8] c"Allocating 64k pages > 128TB \00"
@str.13 = [31 x i8] c"Allocating 16M chunks > 128TB \00"
@str.14 = [31 x i8] c"Allocating 16G chunks > 128TB \00"
define void @mixed_position_16M() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.7, i64 0, i64 0))
%2 = tail call i32 @mmap_chunks_lower(i32 4000, i32 0)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0))
%4 = load i32, i32* @MAP_HUGETLB
%5 = tail call i32 @mmap_chunks_lower(i32 32, i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.7, i64 0, i64 0))
%7 = tail call i32 @mmap_chunks_lower(i32 4000, i32 0)
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.8, i64 0, i64 0))
%9 = load i32, i32* @MAP_HUGETLB
%10 = tail call i32 @mmap_chunks_lower(i32 32, i32 %9)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.9, i64 0, i64 0))
%12 = load i32, i32* @MAP_HUGETLB
%13 = or i32 %12, -2013265920
%14 = tail call i32 @mmap_chunks_lower(i32 1, i32 %13)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.12, i64 0, i64 0))
%16 = tail call i32 @mmap_chunks_higher(i32 12192, i32 0)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.13, i64 0, i64 0))
%18 = load i32, i32* @MAP_HUGETLB
%19 = tail call i32 @mmap_chunks_higher(i32 32, i32 %18)
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.12, i64 0, i64 0))
%21 = tail call i32 @mmap_chunks_higher(i32 12192, i32 0)
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.13, i64 0, i64 0))
%23 = load i32, i32* @MAP_HUGETLB
%24 = tail call i32 @mmap_chunks_higher(i32 32, i32 %23)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.14, i64 0, i64 0))
%26 = load i32, i32* @MAP_HUGETLB
%27 = or i32 %26, -2013265920
%28 = tail call i32 @mmap_chunks_higher(i32 1, i32 %27)
ret void
}