#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() {
  printf("\nWelcome to mem, version %.1F\n", 1.0);
  printf("\nUsage:\n");
  printf("mem reads the memory from a given PID and writes to a file\n");
  printf(" - May require elevated permissions\n");
  printf("./mem <pid> <out_path>\n");
  printf(" - where <pid> is the target PID to capture\n");
  printf(" - and <out_path> is the local dir to write output\n");
  printf(" If <out_path> is not there, writes to stdout\n");
  printf(" If <pid> is 0, all PIDs will be captured\n\n\n");
}


x86 assembly (clang, -O0):
<usage>:
push   %rbp
mov    %rsp,%rbp
lea    0xeed(%rip),%rdi
movsd  0xedd(%rip),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xef6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfa6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<usage>:
push   %rax
lea    0xee0(%rip),%rdi
movsd  0xed0(%rip),%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xee9(%rip),%rdi
call   1030 <puts@plt>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
lea    0xf14(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf37(%rip),%rdi
call   1030 <puts@plt>
lea    0xf57(%rip),%rdi
call   1030 <puts@plt>
lea    0xf7e(%rip),%rdi
call   1030 <puts@plt>
lea    0xfa0(%rip),%rdi
pop    %rax
jmp    1030 <puts@plt>

LLVM IR (-O0):
@.str = [31 x i8] c"\0AWelcome to mem, version %.1F\0A\00"
@.str.1 = [9 x i8] c"\0AUsage:\0A\00"
@.str.2 = [60 x i8] c"mem reads the memory from a given PID and writes to a file\0A\00"
@.str.3 = [37 x i8] c" - May require elevated permissions\0A\00"
@.str.4 = [24 x i8] c"./mem <pid> <out_path>\0A\00"
@.str.5 = [45 x i8] c" - where <pid> is the target PID to capture\0A\00"
@.str.6 = [52 x i8] c" - and <out_path> is the local dir to write output\0A\00"
@.str.7 = [47 x i8] c" If <out_path> is not there, writes to stdout\0A\00"
@.str.8 = [45 x i8] c" If <pid> is 0, all PIDs will be captured\0A\0A\0A\00"
define void @usage() {
%1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), double 1.000000e+00)
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0))
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.3, i64 0, i64 0))
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0))
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.7, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [31 x i8] c"\0AWelcome to mem, version %.1F\0A\00"
@str = [8 x i8] c"\0AUsage:\00"
@str.9 = [59 x i8] c"mem reads the memory from a given PID and writes to a file\00"
@str.10 = [36 x i8] c" - May require elevated permissions\00"
@str.11 = [23 x i8] c"./mem <pid> <out_path>\00"
@str.12 = [44 x i8] c" - where <pid> is the target PID to capture\00"
@str.13 = [51 x i8] c" - and <out_path> is the local dir to write output\00"
@str.14 = [46 x i8] c" If <out_path> is not there, writes to stdout\00"
@str.15 = [44 x i8] c" If <pid> is 0, all PIDs will be captured\0A\0A\00"
define void @usage() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), double 1.000000e+00)
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @str.9, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.10, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.12, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.13, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str.14, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.15, i64 0, i64 0))
ret void
}