#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 /*<<< orphan*/ kputs(char *);
int /*<<< orphan*/ printf(char *, unsigned int, unsigned int, unsigned int,
                          unsigned int, unsigned int);
void ksh_print_page_table_helper(unsigned sta, unsigned end, unsigned used) {
  if (used) {
    kputs("Used: ");
  } else {
    kputs("Free: ");
  }
  printf("%05x-%05x    %5d-%5d   (%5d frames)\n", sta, end, sta, end,
         end - sta + 1);
}


x86 assembly (clang, -O0):
<ksh_print_page_table_helper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     114c <ksh_print_page_table_helper+0x2c>
lea    0xebe(%rip),%rdi
call   1040 <kputs@plt>
jmp    1158 <ksh_print_page_table_helper+0x38>
lea    0xeb4(%rip),%rdi
call   1040 <kputs@plt>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%r8d
mov    -0x8(%rbp),%r9d
sub    -0x4(%rbp),%r9d
add    $0x1,%r9d
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ksh_print_page_table_helper>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%ebp
test   %edx,%edx
lea    0xed7(%rip),%rax
lea    0xec9(%rip),%rdi
cmove  %rax,%rdi
call   1040 <kputs@plt>
mov    %ebx,%r9d
sub    %ebp,%r9d
add    $0x1,%r9d
lea    0xebd(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"Used: \00"
@.str.1 = [7 x i8] c"Free: \00"
@.str.2 = [37 x i8] c"%05x-%05x %5d-%5d (%5d frames)\0A\00"
define void @ksh_print_page_table_helper(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %6
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @kputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
br label %13
11: ; preds = %3
%12 = call i32 @kputs(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %9
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = load i32, i32* %4
%17 = load i32, i32* %5
%18 = load i32, i32* %5
%19 = load i32, i32* %4
%20 = sub i32 %18, %19
%21 = add i32 %20, 1
%22 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %14, i32 %15, i32 %16, i32 %17, i32 %21)
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"Used: \00"
@.str.1 = [7 x i8] c"Free: \00"
@.str.2 = [37 x i8] c"%05x-%05x %5d-%5d (%5d frames)\0A\00"
define void @ksh_print_page_table_helper(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 0
%5 = select i1 %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0)
%6 = tail call i32 @kputs(i8* %5)
%7 = sub i32 1, %0
%8 = add i32 %7, %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %0, i32 %1, i32 %0, i32 %1, i32 %8)
ret void
}