#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 errno;
int getpid();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ system(char *);
void dumpMap() {
  int errnoSave = errno;
  system("rm -f map");
  int pid = getpid();
  char pidstr[10];
  sprintf(pidstr, "%d", pid);
  char cmd[300] = "cp /proc/";
  strcat(cmd, pidstr);
  strcat(cmd, "/maps map");
  system(cmd);
  errno = errnoSave;
}


x86 assembly (clang, -O0):
<dumpMap>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    0x2e7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
lea    0xe92(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x8(%rbp)
lea    -0x12(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe7f(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x140(%rbp),%rdi
lea    0xe82(%rip),%rsi
mov    $0x12c,%edx
call   1050 <memcpy@plt>
lea    -0x140(%rbp),%rdi
lea    -0x12(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x140(%rbp),%rdi
lea    0xe47(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x140(%rbp),%rdi
call   1040 <system@plt>
mov    -0x4(%rbp),%ecx
mov    0x2dff(%rip),%rax
mov    %ecx,(%rax)
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dumpMap>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x148,%rsp
mov    0x2e7c(%rip),%r15
mov    (%r15),%ebp
lea    0xe92(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
call   1030 <getpid@plt>
lea    0xe89(%rip),%rsi
lea    0x6(%rsp),%r14
mov    %r14,%rdi
mov    %eax,%edx
call   1070 <sprintf@plt>
lea    0xe89(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    $0x12c,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcat@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %ebp,(%r15)
add    $0x148,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i32 0
@.str = [10 x i8] c"rm -f map\00"
@.str.1 = [3 x i8] c"%d\00"
@__const.dumpMap.cmd = [300 x i8] c"cp /proc/\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.2 = [10 x i8] c"/maps map\00"
define void @dumpMap() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i8]
%4 = alloca [300 x i8]
%5 = load i32, i32* @errno
store i32 %5, i32* %1
%6 = call i32 @system(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (...) @getpid()
store i32 %7, i32* %2
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%9 = load i32, i32* %2
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = bitcast [300 x i8]* %4 to i8*
%12 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%14 = call i32 @strcat(i8* %12, i8* %13)
%15 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%16 = call i32 @strcat(i8* %15, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%17 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%18 = call i32 @system(i8* %17)
%19 = load i32, i32* %1
store i32 %19, i32* @errno
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [10 x i8] c"rm -f map\00"
@.str.1 = [3 x i8] c"%d\00"
@__const.dumpMap.cmd = [300 x i8] c"cp /proc/\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.2 = [10 x i8] c"/maps map\00"
define void @dumpMap() {
%1 = alloca [10 x i8]
%2 = alloca [300 x i8]
%3 = load i32, i32* @errno
%4 = tail call i32 @system(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 (...) @getpid()
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%8 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 0
%9 = call i32 @strcat(i8* %8, i8* %6)
%10 = call i32 @strcat(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @system(i8* %8)
store i32 %3, i32* @errno
ret void
}