#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int ashmem_purge_all();
int const getpagesize();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int const, int const);
int main(void) {
  const int pages_purged = ashmem_purge_all();
  if (pages_purged < 0) {
    perror("ashmem_purge_all");
    return EXIT_FAILURE;
  }
  printf("Purged %d pages (%d KBytes)\n", pages_purged,
         pages_purged * getpagesize() / 1024);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1040 <ashmem_purge_all@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    1180 <main+0x40>
lea    0xe96(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    11c0 <main+0x80>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1060 <getpagesize@plt>
mov    -0x10(%rbp),%esi
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
imul   %ecx,%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe62(%rip),%rdi
call   1030 <printf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <ashmem_purge_all@plt>
test   %eax,%eax
js     1181 <main+0x41>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <getpagesize@plt>
mov    %ebx,%ecx
imul   %eax,%ecx
lea    0x3ff(%rcx),%edx
test   %ecx,%ecx
cmovns %ecx,%edx
sar    $0xa,%edx
lea    0xea2(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
pop    %rbx
ret
lea    0xe78(%rip),%rdi
call   1050 <perror@plt>
mov    0x2e4c(%rip),%rax
jmp    117d <main+0x3d>

LLVM IR (-O0):
@.str = [17 x i8] c"ashmem_purge_all\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [29 x i8] c"Purged %d pages (%d KBytes)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (...) @ashmem_purge_all()
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %0
%7 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
store i32 %8, i32* %1
br label %17
9: ; preds = %0
%10 = load i32, i32* %2
%11 = load i32, i32* %2
%12 = call i32 (...) @getpagesize()
%13 = mul nsw i32 %11, %12
%14 = sdiv i32 %13, 1024
%15 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %14)
%16 = load i32, i32* @EXIT_SUCCESS
store i32 %16, i32* %1
br label %17
17: ; preds = %9, %6
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [17 x i8] c"ashmem_purge_all\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [29 x i8] c"Purged %d pages (%d KBytes)\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @ashmem_purge_all()
%2 = icmp slt i32 %1, 0
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %10
5: ; preds = %0
%6 = tail call i32 (...) @getpagesize()
%7 = mul nsw i32 %6, %1
%8 = sdiv i32 %7, 1024
%9 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 %1, i32 %8)
br label %10
10: ; preds = %5, %3
%11 = phi i32* [ @EXIT_FAILURE, %3 ], [ @EXIT_SUCCESS, %5 ]
%12 = load i32, i32* %11
ret i32 %12
}