#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 fixed_position() {
  printf("Allocating 64k pages < 128TB \n");
  mmap_chunks_lower(8000, 0);
  printf("Allocating 16M chunks < 128TB \n");
  mmap_chunks_lower(64, 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(24384, 0);
  printf("Allocating 16M chunks > 128TB \n");
  mmap_chunks_higher(64, MAP_HUGETLB);
  printf("Allocating 16G chunks > 128TB \n");
  mmap_chunks_higher(1, (MAP_HUGETLB | (34 << 26)));
}


x86 assembly (clang, -O0):
<fixed_position>:
push   %rbp
mov    %rsp,%rbp
lea    0xec5(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1f40,%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    $0x40,%edi
call   1050 <mmap_chunks_lower@plt>
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
or     $0x88000000,%esi
mov    $0x1,%edi
call   1050 <mmap_chunks_lower@plt>
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
mov    $0x5f40,%edi
xor    %esi,%esi
call   1040 <mmap_chunks_higher@plt>
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e35(%rip),%rax
mov    (%rax),%esi
mov    $0x40,%edi
call   1040 <mmap_chunks_higher@plt>
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e16(%rip),%rax
mov    (%rax),%esi
or     $0x88000000,%esi
mov    $0x1,%edi
call   1040 <mmap_chunks_higher@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<fixed_position>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1f40,%edi
xor    %esi,%esi
call   1050 <mmap_chunks_lower@plt>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e91(%rip),%r14
mov    (%r14),%esi
mov    $0x40,%edi
call   1050 <mmap_chunks_lower@plt>
lea    0xeca(%rip),%rdi
call   1030 <puts@plt>
mov    $0x88000000,%ebx
mov    (%r14),%esi
or     %ebx,%esi
mov    $0x1,%edi
call   1050 <mmap_chunks_lower@plt>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
mov    $0x5f40,%edi
xor    %esi,%esi
call   1040 <mmap_chunks_higher@plt>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
mov    (%r14),%esi
mov    $0x40,%edi
call   1040 <mmap_chunks_higher@plt>
lea    0xed5(%rip),%rdi
call   1030 <puts@plt>
or     (%r14),%ebx
mov    $0x1,%edi
mov    %ebx,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 @fixed_position() {
%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 8000, 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 64, i32 %4)
%6 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%7 = load i32, i32* @MAP_HUGETLB
%8 = or i32 %7, -2013265920
%9 = call i32 @mmap_chunks_lower(i32 1, i32 %8)
%10 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @mmap_chunks_higher(i32 24384, i32 0)
%12 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
%13 = load i32, i32* @MAP_HUGETLB
%14 = call i32 @mmap_chunks_higher(i32 64, i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
%16 = load i32, i32* @MAP_HUGETLB
%17 = or i32 %16, -2013265920
%18 = call i32 @mmap_chunks_higher(i32 1, i32 %17)
ret void
}

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