#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 */
struct page_directory {
  int dummy;
};

/* Variables and functions */
int page_directory_uninstall_page_table(struct page_directory *, unsigned long);
int page_directory_uninstall_page_tables(struct page_directory *pd,
                                         unsigned long index,
                                         unsigned long count) {
  int err;
  for (err = 0; count && !(err < 0); --count, ++index) {
    err = page_directory_uninstall_page_table(pd, index);
  }
  return err;
}


x86 assembly (clang, -O0):
<page_directory_uninstall_page_tables>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x1d(%rbp)
je     1147 <page_directory_uninstall_page_tables+0x37>
cmpl   $0x0,-0x1c(%rbp)
setl   %al
xor    $0xff,%al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1157 <page_directory_uninstall_page_tables+0x47>
jmp    1184 <page_directory_uninstall_page_tables+0x74>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <page_directory_uninstall_page_table@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112b <page_directory_uninstall_page_tables+0x1b>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<page_directory_uninstall_page_tables>:
push   %r15
push   %r14
push   %rbx
test   %rdx,%rdx
je     114b <page_directory_uninstall_page_tables+0x3b>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
add    $0xffffffffffffffff,%r14
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1030 <page_directory_uninstall_page_table@plt>
add    $0xffffffffffffffff,%r14
jae    114d <page_directory_uninstall_page_tables+0x3d>
add    $0x1,%rbx
test   %eax,%eax
jns    1130 <page_directory_uninstall_page_tables+0x20>
jmp    114d <page_directory_uninstall_page_tables+0x3d>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.page_directory = type { i32 }
define i32 @page_directory_uninstall_page_tables(%struct.page_directory* %0, i64 %1, i64 %2) {
%4 = alloca %struct.page_directory*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
store %struct.page_directory* %0, %struct.page_directory** %4
store i64 %1, i64* %5
store i64 %2, i64* %6
store i32 0, i32* %7
br label %8
8: ; preds = %21, %3
%9 = load i64, i64* %6
%10 = icmp ne i64 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* %7
%13 = icmp slt i32 %12, 0
%14 = xor i1 %13, true
br label %15
15: ; preds = %11, %8
%16 = phi i1 [ false, %8 ], [ %14, %11 ]
br i1 %16, label %17, label %26
17: ; preds = %15
%18 = load %struct.page_directory*, %struct.page_directory** %4
%19 = load i64, i64* %5
%20 = call i32 @page_directory_uninstall_page_table(%struct.page_directory* %18, i64 %19)
store i32 %20, i32* %7
br label %21
21: ; preds = %17
%22 = load i64, i64* %6
%23 = add i64 %22, -1
store i64 %23, i64* %6
%24 = load i64, i64* %5
%25 = add i64 %24, 1
store i64 %25, i64* %5
br label %8
26: ; preds = %15
%27 = load i32, i32* %7
ret i32 %27
}

LLVM IR (-O2):
%struct.page_directory = type { i32 }
define i32 @page_directory_uninstall_page_tables(%struct.page_directory* %0, i64 %1, i64 %2) {
%4 = icmp eq i64 %2, 0
br i1 %4, label %14, label %5
5: ; preds = %3, %5
%6 = phi i64 [ %9, %5 ], [ %2, %3 ]
%7 = phi i64 [ %10, %5 ], [ %1, %3 ]
%8 = tail call i32 @page_directory_uninstall_page_table(%struct.page_directory* %0, i64 %7)
%9 = add i64 %6, -1
%10 = add i64 %7, 1
%11 = icmp ne i64 %9, 0
%12 = icmp sgt i32 %8, -1
%13 = select i1 %11, i1 %12, i1 false
br i1 %13, label %5, label %14
14: ; preds = %5, %3
%15 = phi i32 [ 0, %3 ], [ %8, %5 ]
ret i32 %15
}