#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*/ printf(char *, int, int, int);
void used(int rstart, int i, int j) {
  int rend = i << ((10) + (12));
  rend += j << (12);
  if (rstart == 0xe0000 && rend == 0xe1000)
    return;
  printf("mem:   %08x - %08x (%dk bytes)\n", rstart, rend - 1,
         (rend - rstart) / 1024);
}


x86 assembly (clang, -O0):
<used>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
shl    $0x16,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
shl    $0xc,%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0xe0000,-0x4(%rbp)
jne    1155 <used+0x45>
cmpl   $0xe1000,-0x10(%rbp)
jne    1155 <used+0x45>
jmp    1180 <used+0x70>
mov    -0x4(%rbp),%esi
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x4(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%edx
mov    %eax,%ecx
lea    0xe85(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<used>:
mov    %edi,%eax
shl    $0x16,%esi
shl    $0xc,%edx
add    %esi,%edx
cmp    $0xe0000,%edi
jne    112b <used+0x1b>
cmp    $0xe1000,%edx
jne    112b <used+0x1b>
ret
lea    -0x1(%rdx),%r8d
sub    %eax,%edx
lea    0x3ff(%rdx),%ecx
test   %edx,%edx
cmovns %edx,%ecx
sar    $0xa,%ecx
lea    0xeba(%rip),%rdi
mov    %eax,%esi
mov    %r8d,%edx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [32 x i8] c"mem: %08x - %08x (%dk bytes)\0A\00"
define void @used(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = shl i32 %8, 22
store i32 %9, i32* %7
%10 = load i32, i32* %6
%11 = shl i32 %10, 12
%12 = load i32, i32* %7
%13 = add nsw i32 %12, %11
store i32 %13, i32* %7
%14 = load i32, i32* %4
%15 = icmp eq i32 %14, 917504
br i1 %15, label %16, label %20
16: ; preds = %3
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 921600
br i1 %18, label %19, label %20
19: ; preds = %16
br label %29
20: ; preds = %16, %3
%21 = load i32, i32* %4
%22 = load i32, i32* %7
%23 = sub nsw i32 %22, 1
%24 = load i32, i32* %7
%25 = load i32, i32* %4
%26 = sub nsw i32 %24, %25
%27 = sdiv i32 %26, 1024
%28 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %23, i32 %27)
br label %29
29: ; preds = %20, %19
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"mem: %08x - %08x (%dk bytes)\0A\00"
define void @used(i32 %0, i32 %1, i32 %2) {
%4 = shl i32 %1, 22
%5 = shl i32 %2, 12
%6 = add nsw i32 %5, %4
%7 = icmp eq i32 %0, 917504
%8 = icmp eq i32 %6, 921600
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %15, label %10
10: ; preds = %3
%11 = add nsw i32 %6, -1
%12 = sub nsw i32 %6, %0
%13 = sdiv i32 %12, 1024
%14 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %11, i32 %13)
br label %15
15: ; preds = %3, %10
ret void
}