#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 */
typedef scalar_t__ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ page_flag_name(scalar_t__);
int /*<<< orphan*/ printf(char *, unsigned long, unsigned long,
                          int /*<<< orphan*/);
void show_page_range(unsigned long offset, uint64_t flags) {
  static uint64_t flags0;
  static unsigned long index;
  static unsigned long count;
  if (flags == flags0 && offset == index + count) {
    count++;
    return;
  }
  if (count)
    printf("%lu\t%lu\t%s\n", index, count, page_flag_name(flags0));
  flags0 = flags;
  index = offset;
  count = 1;
}


x86 assembly (clang, -O0):
<show_page_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmp    0x2efd(%rip),%rax
jne    1173 <show_page_range+0x53>
mov    -0x8(%rbp),%rax
mov    0x2ef4(%rip),%rcx
add    0x2ef5(%rip),%rcx
cmp    %rcx,%rax
jne    1173 <show_page_range+0x53>
mov    0x2ee5(%rip),%rax
add    $0x1,%rax
mov    %rax,0x2eda(%rip)
jmp    11da <show_page_range+0xba>
cmpq   $0x0,0x2ecd(%rip)
je     11b9 <show_page_range+0x99>
mov    0x2eb8(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2eb5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0x2e9a(%rip),%rdi
call   1030 <page_flag_name@plt>
mov    -0x20(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    %eax,%ecx
lea    0xe4c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,0x2e74(%rip)
mov    -0x8(%rbp),%rax
mov    %rax,0x2e71(%rip)
movq   $0x1,0x2e6e(%rip)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_page_range>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    0x2f03(%rip),%rdi
cmp    %rsi,%rdi
jne    1156 <show_page_range+0x36>
mov    0x2f07(%rip),%rbx
mov    0x2ef8(%rip),%rax
add    %rbx,%rax
cmp    %r14,%rax
jne    115d <show_page_range+0x3d>
add    $0x1,%rbx
jmp    1195 <show_page_range+0x75>
mov    0x2eeb(%rip),%rbx
test   %rbx,%rbx
je     1182 <show_page_range+0x62>
mov    0x2ed7(%rip),%r12
call   1030 <page_flag_name@plt>
lea    0xe8b(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1040 <printf@plt>
mov    %r15,0x2eaf(%rip)
mov    %r14,0x2eb0(%rip)
mov    $0x1,%ebx
mov    %rbx,0x2eac(%rip)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@show_page_range.flags0 = internal global i64 0
@show_page_range.index = internal global i64 0
@show_page_range.count = internal global i64 0
@.str = [12 x i8] c"%lu\09%lu\09%s\0A\00"
define void @show_page_range(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = load i64, i64* @show_page_range.flags0
%7 = icmp eq i64 %5, %6
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i64, i64* %3
%10 = load i64, i64* @show_page_range.index
%11 = load i64, i64* @show_page_range.count
%12 = add i64 %10, %11
%13 = icmp eq i64 %9, %12
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i64, i64* @show_page_range.count
%16 = add i64 %15, 1
store i64 %16, i64* @show_page_range.count
br label %29
17: ; preds = %8, %2
%18 = load i64, i64* @show_page_range.count
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i64, i64* @show_page_range.index
%22 = load i64, i64* @show_page_range.count
%23 = load i64, i64* @show_page_range.flags0
%24 = call i32 @page_flag_name(i64 %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %21, i64 %22, i32 %24)
br label %26
26: ; preds = %20, %17
%27 = load i64, i64* %4
store i64 %27, i64* @show_page_range.flags0
%28 = load i64, i64* %3
store i64 %28, i64* @show_page_range.index
store i64 1, i64* @show_page_range.count
br label %29
29: ; preds = %26, %14
ret void
}

LLVM IR (-O2):
@show_page_range.flags0 = internal unnamed_addr global i64 0
@show_page_range.index = internal unnamed_addr global i64 0
@show_page_range.count = internal unnamed_addr global i64 0
@.str = [12 x i8] c"%lu\09%lu\09%s\0A\00"
define void @show_page_range(i64 %0, i64 %1) {
%3 = load i64, i64* @show_page_range.flags0
%4 = icmp eq i64 %3, %1
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = load i64, i64* @show_page_range.index
%7 = load i64, i64* @show_page_range.count
%8 = add i64 %7, %6
%9 = icmp eq i64 %8, %0
br i1 %9, label %10, label %14
10: ; preds = %5
%11 = add i64 %7, 1
br label %22
12: ; preds = %2
%13 = load i64, i64* @show_page_range.count
br label %14
14: ; preds = %12, %5
%15 = phi i64 [ %13, %12 ], [ %7, %5 ]
%16 = icmp eq i64 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %14
%18 = load i64, i64* @show_page_range.index
%19 = tail call i32 @page_flag_name(i64 %3)
%20 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i64 %18, i64 %15, i32 %19)
br label %21
21: ; preds = %17, %14
store i64 %1, i64* @show_page_range.flags0
store i64 %0, i64* @show_page_range.index
br label %22
22: ; preds = %21, %10
%23 = phi i64 [ 1, %21 ], [ %11, %10 ]
store i64 %23, i64* @show_page_range.count
ret void
}