#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*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *, char *,
                           char *, char *, char *);
int /*<<< orphan*/ stderr;
void usage(char *argv0) {
  fprintf(
      stderr,
      "Raw memory i/o utility - $Revision: 2.0 $\n\n"
      "%s -v -1|2|4 -r|w|a|o [-l <len>] [-f <file>] <addr> [<value>]\n\n"
      "    -v         Verbose, asks for confirmation\n"
      "    -1|2|4     Sets memory access size in bytes (default byte)\n"
      "    -l <len>   Length in bytes of area to access (defaults to\n"
      "               one access, or whole file length)\n"
      "    -r|w|a|o   Read from or Write to memory (default read)\n"
      "               optional write with modify (and/or)\n"
      "    -f <file>  File to write on memory read, or\n"
      "               to read on memory write\n"
      "    <addr>     The memory address to access\n"
      "    <val>      The value to write (implies -w)\n\n"
      "Examples:\n"
      "    %s 0x1000                  Reads one byte from 0x1000\n"
      "    %s 0x1000 0x12             Writes 0x12 to location 0x1000\n"
      "    %s -2 -l 8 0x1000          Reads 8 words from 0x1000\n"
      "    %s -r -f dmp -l 100 200    Reads 100 bytes from addr 200 to file\n"
      "    %s -w -f img 0x10000       Writes the whole of file to memory\n"
      "\n"
      "Note access size (-1|2|4) does not apply to file based accesses.\n\n",
      argv0, argv0, argv0, argv0, argv0, argv0);
  exit(1);
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x8(%rbp),%rcx
mov    -0x8(%rbp),%r8
mov    -0x8(%rbp),%r9
mov    -0x8(%rbp),%r10
mov    -0x8(%rbp),%rax
lea    0xeac(%rip),%rsi
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

x86 assembly (clang, -O2):
<usage>:
push   %rax
mov    %rdi,%rcx
mov    0x2eb5(%rip),%rax
mov    (%rax),%edi
lea    0xecc(%rip),%rsi
mov    %rcx,%rdx
mov    %rcx,%r8
mov    %rcx,%r9
push   %rcx
push   %rcx
call   1030 <fprintf@plt>
add    $0x10,%rsp
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [1005 x i8] c"Raw memory i/o utility - $Revision: 2.0 $\0A\0A%s -v -1|2|4 -r|w|a|o [-l <len>] [-f <file>] <addr> [<value>]\0A\0A -v Verbose, asks for confirmation\0A -1|2|4 Sets memory access size in bytes (default byte)\0A -l <len> Length in bytes of area to access (defaults to\0A one access, or whole file length)\0A -r|w|a|o Read from or Write to memory (default read)\0A optional write with modify (and/or)\0A -f <file> File to write on memory read, or\0A to read on memory write\0A <addr> The memory address to access\0A <val> The value to write (implies -w)\0A\0AExamples:\0A %s 0x1000 Reads one byte from 0x1000\0A %s 0x1000 0x12 Writes 0x12 to location 0x1000\0A %s -2 -l 8 0x1000 Reads 8 words from 0x1000\0A %s -r -f dmp -l 100 200 Reads 100 bytes from addr 200 to file\0A %s -w -f img 0x10000 Writes the whole of file to memory\0A\0ANote access size (-1|2|4) does not apply to file based accesses.\0A\0A\00"
define void @usage(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = load i32, i32* @stderr
%4 = load i8*, i8** %2
%5 = load i8*, i8** %2
%6 = load i8*, i8** %2
%7 = load i8*, i8** %2
%8 = load i8*, i8** %2
%9 = load i8*, i8** %2
%10 = call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([1005 x i8], [1005 x i8]* @.str, i64 0, i64 0), i8* %4, i8* %5, i8* %6, i8* %7, i8* %8, i8* %9)
%11 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [1005 x i8] c"Raw memory i/o utility - $Revision: 2.0 $\0A\0A%s -v -1|2|4 -r|w|a|o [-l <len>] [-f <file>] <addr> [<value>]\0A\0A -v Verbose, asks for confirmation\0A -1|2|4 Sets memory access size in bytes (default byte)\0A -l <len> Length in bytes of area to access (defaults to\0A one access, or whole file length)\0A -r|w|a|o Read from or Write to memory (default read)\0A optional write with modify (and/or)\0A -f <file> File to write on memory read, or\0A to read on memory write\0A <addr> The memory address to access\0A <val> The value to write (implies -w)\0A\0AExamples:\0A %s 0x1000 Reads one byte from 0x1000\0A %s 0x1000 0x12 Writes 0x12 to location 0x1000\0A %s -2 -l 8 0x1000 Reads 8 words from 0x1000\0A %s -r -f dmp -l 100 200 Reads 100 bytes from addr 200 to file\0A %s -w -f img 0x10000 Writes the whole of file to memory\0A\0ANote access size (-1|2|4) does not apply to file based accesses.\0A\0A\00"
define void @usage(i8* %0) {
%2 = load i32, i32* @stderr
%3 = tail call i32 @fprintf(i32 %2, i8* getelementptr inbounds ([1005 x i8], [1005 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %0, i8* %0, i8* %0, i8* %0, i8* %0)
%4 = tail call i32 @exit(i32 1)
unreachable
}