#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 *, ...);
void usage(char *prog) {
  printf("+++++++++++++++++++\n");
  printf("phymem version:%1.1f\n", 1.0);
  printf("+++++++++++++++++++\n");
  printf("Usage: %s -p <Physical Address> [-l <Length>] [-w <-d <data>>|-f] "
         "[-n <lines per page>]\n\n",
         prog);
  printf("%s is a utility to view and modify physical memory\n", prog);
  printf("Flags explanation:\n");
  printf("-p physical address where read or write operation should perform\n");
  printf("-l the length data should read or write\n");
  printf("-w write flag to enable write operation\n");
  printf("-d actual data will be write to the physical memory. Must be using "
         "with -w flag\n");
  printf("-f fill address with content being its address\n");
  printf("-n lines per page, each line contains 16 bytes\n");
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
movsd  0xec7(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xec1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xf22(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xffb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0x101d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xf7e(%rip),%r14
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xecb(%rip),%rdi
movsd  0xebb(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
lea    0xec3(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf0c(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf43(%rip),%rdi
call   1030 <puts@plt>
lea    0xf4a(%rip),%rdi
call   1030 <puts@plt>
lea    0xf7f(%rip),%rdi
call   1030 <puts@plt>
lea    0xf9b(%rip),%rdi
call   1030 <puts@plt>
lea    0xfb7(%rip),%rdi
call   1030 <puts@plt>
lea    0xffb(%rip),%rdi
call   1030 <puts@plt>
lea    0x101e(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"+++++++++++++++++++\0A\00"
@.str.1 = [22 x i8] c"phymem version:%1.1f\0A\00"
@.str.2 = [90 x i8] c"Usage: %s -p <Physical Address> [-l <Length>] [-w <-d <data>>|-f] [-n <lines per page>]\0A\0A\00"
@.str.3 = [52 x i8] c"%s is a utility to view and modify physical memory\0A\00"
@.str.4 = [20 x i8] c"Flags explanation:\0A\00"
@.str.5 = [66 x i8] c"-p physical address where read or write operation should perform\0A\00"
@.str.6 = [41 x i8] c"-l the length data should read or write\0A\00"
@.str.7 = [41 x i8] c"-w write flag to enable write operation\0A\00"
@.str.8 = [81 x i8] c"-d actual data will be write to the physical memory. Must be using with -w flag\0A\00"
@.str.9 = [48 x i8] c"-f fill address with content being its address\0A\00"
@.str.10 = [48 x i8] c"-n lines per page, each line contains 16 bytes\0A\00"
define void @usage(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double 1.000000e+00)
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%8 = load i8*, i8** %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* %8)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str.5, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.8, i64 0, i64 0))
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.9, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"phymem version:%1.1f\0A\00"
@.str.2 = [90 x i8] c"Usage: %s -p <Physical Address> [-l <Length>] [-w <-d <data>>|-f] [-n <lines per page>]\0A\0A\00"
@.str.3 = [52 x i8] c"%s is a utility to view and modify physical memory\0A\00"
@str.11 = [20 x i8] c"+++++++++++++++++++\00"
@str.12 = [19 x i8] c"Flags explanation:\00"
@str.13 = [65 x i8] c"-p physical address where read or write operation should perform\00"
@str.14 = [40 x i8] c"-l the length data should read or write\00"
@str.15 = [40 x i8] c"-w write flag to enable write operation\00"
@str.16 = [80 x i8] c"-d actual data will be write to the physical memory. Must be using with -w flag\00"
@str.17 = [47 x i8] c"-f fill address with content being its address\00"
@str.18 = [47 x i8] c"-n lines per page, each line contains 16 bytes\00"
define void @usage(i8* %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), double 1.000000e+00)
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0), i8* %0)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.12, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @str.13, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.14, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.15, i64 0, i64 0))
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str.16, i64 0, i64 0))
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.17, i64 0, i64 0))
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str.18, i64 0, i64 0))
ret void
}