#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 count_present(unsigned char *, int, int *);
int /*<<< orphan*/ printf(char *, char *, int, int, int, int, char *);
void basic_info(char *fname, unsigned char *vec, int npg) {
  int nrun = 0, npresent;
  npresent = count_present(vec, npg, &nrun);
  printf("%s: %d/%d pages present (%d%%, %d run%s)\n", fname, npresent, npg,
         npg ? npresent * 100 / npg : 0, nrun, nrun == 1 ? "" : "s");
}


x86 assembly (clang, -O0):
<basic_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x18(%rbp),%rdx
call   1040 <count_present@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     117b <basic_info+0x5b>
imul   $0x64,-0x1c(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x34(%rbp)
jmp    1185 <basic_info+0x65>
xor    %eax,%eax
mov    %eax,-0x34(%rbp)
jmp    1185 <basic_info+0x65>
mov    -0x20(%rbp),%ecx
mov    -0x24(%rbp),%edx
mov    -0x30(%rbp),%rsi
mov    -0x34(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x18(%rbp),%r10d
lea    0xe88(%rip),%rax
lea    0xe80(%rip),%rdi
cmp    $0x1,%r10d
cmove  %rdi,%rax
lea    0xe48(%rip),%rdi
mov    %rax,(%rsp)
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<basic_info>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %rdi,%r14
movl   $0x0,0x14(%rsp)
lea    0x14(%rsp),%rdx
mov    %rsi,%rdi
mov    %ebx,%esi
call   1040 <count_present@plt>
mov    %eax,%ecx
test   %ebx,%ebx
je     1154 <basic_info+0x34>
imul   $0x64,%ecx,%eax
cltd
idiv   %ebx
mov    %eax,%r8d
jmp    1157 <basic_info+0x37>
xor    %r8d,%r8d
mov    0x14(%rsp),%r9d
cmp    $0x1,%r9d
lea    0xec2(%rip),%rax
lea    0xebc(%rip),%rdx
cmove  %rax,%rdx
mov    %rdx,(%rsp)
lea    0xe83(%rip),%rdi
mov    %r14,%rsi
mov    %ecx,%edx
mov    %ebx,%ecx
call   1030 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [42 x i8] c"%s: %d/%d pages present (%d%%, %d run%s)\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"s\00"
define void @basic_info(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%9 = load i8*, i8** %5
%10 = load i32, i32* %6
%11 = call i32 @count_present(i8* %9, i32 %10, i32* %7)
store i32 %11, i32* %8
%12 = load i8*, i8** %4
%13 = load i32, i32* %8
%14 = load i32, i32* %6
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %3
%18 = load i32, i32* %8
%19 = mul nsw i32 %18, 100
%20 = load i32, i32* %6
%21 = sdiv i32 %19, %20
br label %23
22: ; preds = %3
br label %23
23: ; preds = %22, %17
%24 = phi i32 [ %21, %17 ], [ 0, %22 ]
%25 = load i32, i32* %7
%26 = load i32, i32* %7
%27 = icmp eq i32 %26, 1
%28 = zext i1 %27 to i64
%29 = select i1 %27, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%30 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %12, i32 %13, i32 %14, i32 %24, i32 %25, i8* %29)
ret void
}

LLVM IR (-O2):
@.str = [42 x i8] c"%s: %d/%d pages present (%d%%, %d run%s)\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [2 x i8] c"s\00"
define void @basic_info(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%6 = call i32 @count_present(i8* %1, i32 %2, i32* %4)
%7 = icmp eq i32 %2, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = mul nsw i32 %6, 100
%10 = sdiv i32 %9, %2
br label %11
11: ; preds = %3, %8
%12 = phi i32 [ %10, %8 ], [ 0, %3 ]
%13 = load i32, i32* %4
%14 = icmp eq i32 %13, 1
%15 = select i1 %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%16 = call i32 @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %6, i32 %2, i32 %12, i32 %13, i8* %15)
ret void
}