#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 get_hugepage_mbytes();
int set_alt_hugepage() {
  int size = get_hugepage_mbytes();
  if (size == 16384)
    return MAP_HUGETLB | (24 << 26);
  else if (size == 1024)
    return MAP_HUGETLB | (21 << 26);
  else if (size == 2)
    return MAP_HUGETLB | (30 << 26);
  else
    return MAP_HUGETLB | (34 << 26);
}


x86 assembly (clang, -O0):
<set_alt_hugepage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1030 <get_hugepage_mbytes@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x4000,-0x8(%rbp)
jne    1145 <set_alt_hugepage+0x35>
mov    0x2eba(%rip),%rax
mov    (%rax),%eax
or     $0x60000000,%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <set_alt_hugepage+0x89>
cmpl   $0x400,-0x8(%rbp)
jne    1168 <set_alt_hugepage+0x58>
mov    0x2e97(%rip),%rax
mov    (%rax),%eax
or     $0x54000000,%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <set_alt_hugepage+0x89>
cmpl   $0x2,-0x8(%rbp)
jne    1188 <set_alt_hugepage+0x78>
mov    0x2e77(%rip),%rax
mov    (%rax),%eax
or     $0x78000000,%eax
mov    %eax,-0x4(%rbp)
jmp    1199 <set_alt_hugepage+0x89>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
or     $0x88000000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_alt_hugepage>:
push   %rax
xor    %eax,%eax
call   1030 <get_hugepage_mbytes@plt>
cmp    $0x2,%eax
je     1132 <set_alt_hugepage+0x22>
cmp    $0x4000,%eax
je     1139 <set_alt_hugepage+0x29>
cmp    $0x400,%eax
jne    1140 <set_alt_hugepage+0x30>
mov    $0x54000000,%eax
jmp    1145 <set_alt_hugepage+0x35>
mov    $0x78000000,%eax
jmp    1145 <set_alt_hugepage+0x35>
mov    $0x60000000,%eax
jmp    1145 <set_alt_hugepage+0x35>
mov    $0x88000000,%eax
mov    0x2ea4(%rip),%rcx
or     (%rcx),%eax
pop    %rcx
ret

LLVM IR (-O0):
@MAP_HUGETLB = global i32 0
define i32 @set_alt_hugepage() {
%1 = alloca i32
%2 = alloca i32
%3 = call i32 (...) @get_hugepage_mbytes()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, 16384
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = load i32, i32* @MAP_HUGETLB
%8 = or i32 %7, 1610612736
store i32 %8, i32* %1
br label %24
9: ; preds = %0
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 1024
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* @MAP_HUGETLB
%14 = or i32 %13, 1409286144
store i32 %14, i32* %1
br label %24
15: ; preds = %9
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = load i32, i32* @MAP_HUGETLB
%20 = or i32 %19, 2013265920
store i32 %20, i32* %1
br label %24
21: ; preds = %15
%22 = load i32, i32* @MAP_HUGETLB
%23 = or i32 %22, -2013265920
store i32 %23, i32* %1
br label %24
24: ; preds = %21, %18, %12, %6
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@MAP_HUGETLB = global i32 0
define i32 @set_alt_hugepage() {
%1 = tail call i32 (...) @get_hugepage_mbytes()
switch i32 %1, label %4 [
i32 16384, label %5
i32 1024, label %2
i32 2, label %3
]
2: ; preds = %0
br label %5
3: ; preds = %0
br label %5
4: ; preds = %0
br label %5
5: ; preds = %0, %4, %3, %2
%6 = phi i32 [ -2013265920, %4 ], [ 2013265920, %3 ], [ 1409286144, %2 ], [ 1610612736, %0 ]
%7 = load i32, i32* @MAP_HUGETLB
%8 = or i32 %7, %6
ret i32 %8
}