#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*/ DEBUG_ECHO(char *);
int /*<<< orphan*/ DEBUG_PRINT(char *);
int /*<<< orphan*/ KiB(int);
char *itoa(int, char *, int);
scalar_t__ pagealloc_alloc(int /*<<< orphan*/, int /*<<< orphan*/,
                           int /*<<< orphan*/, int /*<<< orphan*/);
int pmem_initial_test() {
  DEBUG_ECHO("Starting SysPhysicalMemory test set 1...\r\n");
  for (int i = 0; i < 16; i++) {
    char tmp_buf[10];
    DEBUG_PRINT(itoa((int)pagealloc_alloc(0, 0, 0, KiB(4)), tmp_buf, 16));
    DEBUG_PRINT("\r\n");
  }
  DEBUG_ECHO("Test passed!\r\n");
  return 0;
}


x86 assembly (clang, -O0):
<pmem_initial_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1060 <DEBUG_ECHO@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x10,-0x4(%rbp)
jge    11be <pmem_initial_test+0x6e>
mov    $0x4,%edi
call   1030 <KiB@plt>
mov    %eax,%ecx
xor    %edx,%edx
mov    %edx,%edi
mov    %edx,%esi
call   1040 <pagealloc_alloc@plt>
mov    %eax,%edi
lea    -0xe(%rbp),%rsi
mov    $0x10,%edx
call   1070 <itoa@plt>
mov    %rax,%rdi
call   1050 <DEBUG_PRINT@plt>
lea    0xe8c(%rip),%rdi
call   1050 <DEBUG_PRINT@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    116b <pmem_initial_test+0x1b>
lea    0xe66(%rip),%rdi
call   1060 <DEBUG_ECHO@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pmem_initial_test>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1060 <DEBUG_ECHO@plt>
mov    $0x10,%ebp
lea    0x6(%rsp),%r14
lea    0xec2(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x4,%edi
call   1030 <KiB@plt>
xor    %edi,%edi
xor    %esi,%esi
xor    %edx,%edx
mov    %eax,%ecx
call   1040 <pagealloc_alloc@plt>
mov    %eax,%edi
mov    %r14,%rsi
mov    $0x10,%edx
call   1070 <itoa@plt>
mov    %rax,%rdi
call   1050 <DEBUG_PRINT@plt>
mov    %rbx,%rdi
call   1050 <DEBUG_PRINT@plt>
add    $0xffffffff,%ebp
jne    1180 <pmem_initial_test+0x30>
lea    0xe69(%rip),%rdi
call   1060 <DEBUG_ECHO@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Starting SysPhysicalMemory test set 1...\0D\0A\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
@.str.2 = [15 x i8] c"Test passed!\0D\0A\00"
define i32 @pmem_initial_test() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = call i32 @DEBUG_ECHO(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %4
4: ; preds = %15, %0
%5 = load i32, i32* %1
%6 = icmp slt i32 %5, 16
br i1 %6, label %7, label %18
7: ; preds = %4
%8 = call i32 @KiB(i32 4)
%9 = call i64 @pagealloc_alloc(i32 0, i32 0, i32 0, i32 %8)
%10 = trunc i64 %9 to i32
%11 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%12 = call i8* @itoa(i32 %10, i8* %11, i32 16)
%13 = call i32 @DEBUG_PRINT(i8* %12)
%14 = call i32 @DEBUG_PRINT(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %7
%16 = load i32, i32* %1
%17 = add nsw i32 %16, 1
store i32 %17, i32* %1
br label %4
18: ; preds = %4
%19 = call i32 @DEBUG_ECHO(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [43 x i8] c"Starting SysPhysicalMemory test set 1...\0D\0A\00"
@.str.1 = [3 x i8] c"\0D\0A\00"
@.str.2 = [15 x i8] c"Test passed!\0D\0A\00"
define i32 @pmem_initial_test() {
%1 = alloca [10 x i8]
%2 = tail call i32 @DEBUG_ECHO(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
br label %6
4: ; preds = %6
%5 = call i32 @DEBUG_ECHO(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
6: ; preds = %0, %6
%7 = phi i32 [ 0, %0 ], [ %14, %6 ]
%8 = call i32 @KiB(i32 4)
%9 = call i64 @pagealloc_alloc(i32 0, i32 0, i32 0, i32 %8)
%10 = trunc i64 %9 to i32
%11 = call i8* @itoa(i32 %10, i8* %3, i32 16)
%12 = call i32 @DEBUG_PRINT(i8* %11)
%13 = call i32 @DEBUG_PRINT(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = add nuw nsw i32 %7, 1
%15 = icmp eq i32 %14, 16
br i1 %15, label %4, label %6
}