#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 */
typedef int ssize_t;
typedef int pid_t;
typedef scalar_t__ off_t;

/* Variables and functions */
int ENOMEM;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ PTRACE_ATTACH;
int /*<<< orphan*/ PTRACE_DETACH;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ _exit(int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ hexdump(char *, char *, long);
scalar_t__ lseek(int, scalar_t__, int /*<<< orphan*/);
char *malloc(long);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, int, char *, long);
int /*<<< orphan*/ ptrace(int /*<<< orphan*/, int, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int read(int, char *, long);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ stderr;
int wait(int *);
int main(int argc, char **argv) {
  pid_t pid;
  char *start;
  long length;
  int fd;
  ssize_t size_read;
  off_t seeked_to;
  int wait_status;
  char filename[80];
  char *buffer;
  pid_t wait_pid;
  if (argc < 3) {
    fprintf(stderr, "Usage: dumpmem <pid> <start> <length>\n");
    _exit(1);
  }
  sscanf(argv[1], "%d", &pid);
  sscanf(argv[2], "%p", &start);
  sscanf(argv[3], "%x", &length);
  printf("Dumping pid %d [%p(%d)]\n", pid, start, length);
  buffer = malloc(length);
  if (buffer == NULL) {
    fprintf(stderr, "memory allocation error\n");
    _exit(ENOMEM);
  }
  ptrace(PTRACE_ATTACH, pid, 0, 0);
  wait_pid = wait(&wait_status);
  if (wait_pid == -1) {
    perror("waitpid");
    _exit(0);
  }
  if (wait_pid != pid) {
    fprintf(stderr, "didn't wait for %d\n", pid);
  }
  sprintf(filename, "/proc/%d/mem", pid);
  fd = open(filename, O_RDONLY);
  if (fd < 0) {
    perror("open");
    ptrace(PTRACE_DETACH, pid, 0, 0);
    _exit(0);
  }
  seeked_to = lseek(fd, (off_t)start, SEEK_SET);
  if (seeked_to == (off_t)-1) {
    perror("lseek");
    goto finish;
  }
  size_read = read(fd, buffer, length);
  if (size_read == -1) {
    perror("read");
    goto finish;
  }
  if (size_read != length) {
    fprintf(stderr, "expected to read %d bytes, but read %d bytes\n", length,
            size_read);
    _exit(1);
  }
  hexdump(start, buffer, length);
finish:
  close(fd);
  ptrace(PTRACE_DETACH, pid, 0, 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    1224 <main+0x44>
mov    0x2db6(%rip),%rax
mov    (%rax),%edi
lea    0xded(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf4(%rip),%rsi
lea    -0x14(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xddd(%rip),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xdc6(%rip),%rsi
lea    -0x28(%rbp),%rdx
mov    $0x0,%al
call   10b0 <sscanf@plt>
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
lea    0xdac(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
jne    12cc <main+0xec>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
lea    0xd92(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   10c0 <ptrace@plt>
lea    -0x3c(%rbp),%rdi
call   1100 <wait@plt>
mov    %eax,-0x9c(%rbp)
cmpl   $0xffffffff,-0x9c(%rbp)
jne    1310 <main+0x130>
lea    0xd5e(%rip),%rdi
call   10e0 <perror@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
mov    -0x9c(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     1339 <main+0x159>
mov    0x2c9a(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xd34(%rip),%rsi
call   10f0 <sprintf@plt>
lea    -0x90(%rbp),%rdi
mov    0x2c8b(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x0,-0x2c(%rbp)
jge    1399 <main+0x1b9>
lea    0xd13(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2c5c(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   10c0 <ptrace@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    0x2c11(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0xffffffffffffffff,-0x38(%rbp)
jne    13ce <main+0x1ee>
lea    0xccc(%rip),%rdi
call   10e0 <perror@plt>
jmp    1449 <main+0x269>
mov    -0x2c(%rbp),%edi
mov    -0x98(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1070 <read@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
jne    13ff <main+0x21f>
lea    0xca1(%rip),%rdi
call   10e0 <perror@plt>
jmp    1449 <main+0x269>
movslq -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
je     1435 <main+0x255>
mov    0x2bac(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%ecx
lea    0xc77(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
mov    -0x20(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1090 <hexdump@plt>
mov    -0x2c(%rbp),%edi
call   1060 <close@plt>
mov    0x2b88(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%esi
xor    %ecx,%ecx
mov    %ecx,%edx
call   10c0 <ptrace@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x78,%rsp
cmp    $0x2,%edi
jle    1376 <main+0x196>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe2a(%rip),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   10b0 <sscanf@plt>
mov    0x10(%rbx),%rdi
lea    0xe16(%rip),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   10b0 <sscanf@plt>
mov    0x18(%rbx),%rdi
lea    0xe02(%rip),%rsi
lea    0x8(%rsp),%rdx
xor    %eax,%eax
call   10b0 <sscanf@plt>
mov    0x4(%rsp),%esi
mov    0x10(%rsp),%rdx
mov    0x8(%rsp),%rcx
lea    0xde4(%rip),%rdi
call   1040 <printf@plt>
mov    0x8(%rsp),%rdi
call   10a0 <malloc@plt>
test   %rax,%rax
je     1397 <main+0x1b7>
mov    %rax,%rbx
mov    0x2d6a(%rip),%rax
mov    (%rax),%edi
mov    0x4(%rsp),%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10c0 <ptrace@plt>
lea    0x1c(%rsp),%rdi
call   1100 <wait@plt>
cmp    $0xffffffff,%eax
je     13bc <main+0x1dc>
mov    0x4(%rsp),%edx
cmp    %edx,%eax
je     12b3 <main+0xd3>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xdc2(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x4(%rsp),%eax
lea    0xdc4(%rip),%rsi
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    %eax,%edx
call   10f0 <sprintf@plt>
mov    0x2d18(%rip),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   10d0 <open@plt>
test   %eax,%eax
js     13cf <main+0x1ef>
mov    %eax,%ebp
mov    0x10(%rsp),%rsi
mov    0x2cc8(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
call   1050 <lseek@plt>
cmp    $0xffffffffffffffff,%rax
je     135a <main+0x17a>
mov    0x8(%rsp),%rdx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1070 <read@plt>
cmp    $0xffffffff,%eax
je     1368 <main+0x188>
movslq %eax,%rcx
mov    0x8(%rsp),%rdx
cmp    %rcx,%rdx
jne    13f8 <main+0x218>
mov    0x10(%rsp),%rdi
mov    %rbx,%rsi
mov    %rcx,%rdx
call   1090 <hexdump@plt>
mov    %ebp,%edi
call   1060 <close@plt>
mov    0x2c9e(%rip),%rax
mov    (%rax),%edi
mov    0x4(%rsp),%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10c0 <ptrace@plt>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xd2f(%rip),%rdi
call   10e0 <perror@plt>
jmp    1334 <main+0x154>
lea    0xd27(%rip),%rdi
call   10e0 <perror@plt>
jmp    1334 <main+0x154>
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
lea    0xc7a(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>
mov    0x2c22(%rip),%rax
mov    (%rax),%edi
lea    0xca2(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
call   1030 <_exit@plt>
lea    0xc9f(%rip),%rdi
call   10e0 <perror@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
lea    0xcb5(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2bfe(%rip),%rax
mov    (%rax),%edi
mov    0x4(%rsp),%esi
xor    %edx,%edx
xor    %ecx,%ecx
call   10c0 <ptrace@plt>
xor    %edi,%edi
call   1030 <_exit@plt>
mov    0x2bc1(%rip),%rcx
mov    (%rcx),%edi
lea    0xc93(%rip),%rsi
mov    %eax,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   1030 <_exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [39 x i8] c"Usage: dumpmem <pid> <start> <length>\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%p\00"
@.str.3 = [3 x i8] c"%x\00"
@.str.4 = [25 x i8] c"Dumping pid %d [%p(%d)]\0A\00"
@.str.5 = [25 x i8] c"memory allocation error\0A\00"
@ENOMEM = global i32 0
@PTRACE_ATTACH = global i32 0
@.str.6 = [8 x i8] c"waitpid\00"
@.str.7 = [20 x i8] c"didn't wait for %d\0A\00"
@.str.8 = [13 x i8] c"/proc/%d/mem\00"
@O_RDONLY = global i32 0
@.str.9 = [5 x i8] c"open\00"
@PTRACE_DETACH = global i32 0
@SEEK_SET = global i32 0
@.str.10 = [6 x i8] c"lseek\00"
@.str.11 = [5 x i8] c"read\00"
@.str.12 = [46 x i8] c"expected to read %d bytes, but read %d bytes\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i32
%13 = alloca [80 x i8]
%14 = alloca i8*
%15 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 3
br i1 %17, label %18, label %22
18: ; preds = %2
%19 = load i32, i32* @stderr
%20 = call i32 (i32, i8*, ...) @fprintf(i32 %19, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%21 = call i32 @_exit(i32 1)
unreachable
22: ; preds = %2
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = call i32 (i8*, i8*, ...) @sscanf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 2
%29 = load i8*, i8** %28
%30 = call i32 (i8*, i8*, ...) @sscanf(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %7)
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 3
%33 = load i8*, i8** %32
%34 = call i32 (i8*, i8*, ...) @sscanf(i8* %33, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64* %8)
%35 = load i32, i32* %6
%36 = load i8*, i8** %7
%37 = load i64, i64* %8
%38 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %35, i8* %36, i64 %37)
%39 = load i64, i64* %8
%40 = call i8* @malloc(i64 %39)
store i8* %40, i8** %14
%41 = load i8*, i8** %14
%42 = icmp eq i8* %41, null
br i1 %42, label %43, label %48
43: ; preds = %22
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%46 = load i32, i32* @ENOMEM
%47 = call i32 @_exit(i32 %46)
unreachable
48: ; preds = %22
%49 = load i32, i32* @PTRACE_ATTACH
%50 = load i32, i32* %6
%51 = call i32 @ptrace(i32 %49, i32 %50, i32 0, i32 0)
%52 = call i32 @wait(i32* %12)
store i32 %52, i32* %15
%53 = load i32, i32* %15
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %58
55: ; preds = %48
%56 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%57 = call i32 @_exit(i32 0)
unreachable
58: ; preds = %48
%59 = load i32, i32* %15
%60 = load i32, i32* %6
%61 = icmp ne i32 %59, %60
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = load i32, i32* %6
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %62, %58
%67 = getelementptr inbounds [80 x i8], [80 x i8]* %13, i64 0, i64 0
%68 = load i32, i32* %6
%69 = call i32 @sprintf(i8* %67, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %68)
%70 = getelementptr inbounds [80 x i8], [80 x i8]* %13, i64 0, i64 0
%71 = load i32, i32* @O_RDONLY
%72 = call i32 @open(i8* %70, i32 %71)
store i32 %72, i32* %9
%73 = load i32, i32* %9
%74 = icmp slt i32 %73, 0
br i1 %74, label %75, label %81
75: ; preds = %66
%76 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%77 = load i32, i32* @PTRACE_DETACH
%78 = load i32, i32* %6
%79 = call i32 @ptrace(i32 %77, i32 %78, i32 0, i32 0)
%80 = call i32 @_exit(i32 0)
unreachable
81: ; preds = %66
%82 = load i32, i32* %9
%83 = load i8*, i8** %7
%84 = ptrtoint i8* %83 to i64
%85 = load i32, i32* @SEEK_SET
%86 = call i64 @lseek(i32 %82, i64 %84, i32 %85)
store i64 %86, i64* %11
%87 = load i64, i64* %11
%88 = icmp eq i64 %87, -1
br i1 %88, label %89, label %91
89: ; preds = %81
%90 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %116
91: ; preds = %81
%92 = load i32, i32* %9
%93 = load i8*, i8** %14
%94 = load i64, i64* %8
%95 = call i32 @read(i32 %92, i8* %93, i64 %94)
store i32 %95, i32* %10
%96 = load i32, i32* %10
%97 = icmp eq i32 %96, -1
br i1 %97, label %98, label %100
98: ; preds = %91
%99 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %116
100: ; preds = %91
%101 = load i32, i32* %10
%102 = sext i32 %101 to i64
%103 = load i64, i64* %8
%104 = icmp ne i64 %102, %103
br i1 %104, label %105, label %111
105: ; preds = %100
%106 = load i32, i32* @stderr
%107 = load i64, i64* %8
%108 = load i32, i32* %10
%109 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.12, i64 0, i64 0), i64 %107, i32 %108)
%110 = call i32 @_exit(i32 1)
unreachable
111: ; preds = %100
%112 = load i8*, i8** %7
%113 = load i8*, i8** %14
%114 = load i64, i64* %8
%115 = call i32 @hexdump(i8* %112, i8* %113, i64 %114)
br label %116
116: ; preds = %111, %98, %89
%117 = load i32, i32* %9
%118 = call i32 @close(i32 %117)
%119 = load i32, i32* @PTRACE_DETACH
%120 = load i32, i32* %6
%121 = call i32 @ptrace(i32 %119, i32 %120, i32 0, i32 0)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [39 x i8] c"Usage: dumpmem <pid> <start> <length>\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%p\00"
@.str.3 = [3 x i8] c"%x\00"
@.str.4 = [25 x i8] c"Dumping pid %d [%p(%d)]\0A\00"
@.str.5 = [25 x i8] c"memory allocation error\0A\00"
@ENOMEM = global i32 0
@PTRACE_ATTACH = global i32 0
@.str.6 = [8 x i8] c"waitpid\00"
@.str.7 = [20 x i8] c"didn't wait for %d\0A\00"
@.str.8 = [13 x i8] c"/proc/%d/mem\00"
@O_RDONLY = global i32 0
@.str.9 = [5 x i8] c"open\00"
@PTRACE_DETACH = global i32 0
@SEEK_SET = global i32 0
@.str.10 = [6 x i8] c"lseek\00"
@.str.11 = [5 x i8] c"read\00"
@.str.12 = [46 x i8] c"expected to read %d bytes, but read %d bytes\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i32
%7 = alloca [80 x i8]
%8 = bitcast i32* %3 to i8*
%9 = bitcast i8** %4 to i8*
%10 = bitcast i64* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = getelementptr inbounds [80 x i8], [80 x i8]* %7, i64 0, i64 0
%13 = icmp slt i32 %0, 3
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @_exit(i32 1)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i8*, i8*, ...) @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%22 = getelementptr inbounds i8*, i8** %1, i64 2
%23 = load i8*, i8** %22
%24 = call i32 (i8*, i8*, ...) @sscanf(i8* %23, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %4)
%25 = getelementptr inbounds i8*, i8** %1, i64 3
%26 = load i8*, i8** %25
%27 = call i32 (i8*, i8*, ...) @sscanf(i8* %26, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64* %5)
%28 = load i32, i32* %3
%29 = load i8*, i8** %4
%30 = load i64, i64* %5
%31 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %28, i8* %29, i64 %30)
%32 = load i64, i64* %5
%33 = call i8* @malloc(i64 %32)
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %40
35: ; preds = %18
%36 = load i32, i32* @stderr
%37 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%38 = load i32, i32* @ENOMEM
%39 = call i32 @_exit(i32 %38)
unreachable
40: ; preds = %18
%41 = load i32, i32* @PTRACE_ATTACH
%42 = load i32, i32* %3
%43 = call i32 @ptrace(i32 %41, i32 %42, i32 0, i32 0)
%44 = call i32 @wait(i32* %6)
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %49
46: ; preds = %40
%47 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%48 = call i32 @_exit(i32 0)
unreachable
49: ; preds = %40
%50 = load i32, i32* %3
%51 = icmp eq i32 %44, %50
br i1 %51, label %56, label %52
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %50)
%55 = load i32, i32* %3
br label %56
56: ; preds = %52, %49
%57 = phi i32 [ %55, %52 ], [ %44, %49 ]
%58 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %57)
%59 = load i32, i32* @O_RDONLY
%60 = call i32 @open(i8* %12, i32 %59)
%61 = icmp slt i32 %60, 0
br i1 %61, label %62, label %68
62: ; preds = %56
%63 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.9, i64 0, i64 0))
%64 = load i32, i32* @PTRACE_DETACH
%65 = load i32, i32* %3
%66 = call i32 @ptrace(i32 %64, i32 %65, i32 0, i32 0)
%67 = call i32 @_exit(i32 0)
unreachable
68: ; preds = %56
%69 = load i8*, i8** %4
%70 = ptrtoint i8* %69 to i64
%71 = load i32, i32* @SEEK_SET
%72 = call i64 @lseek(i32 %60, i64 %70, i32 %71)
%73 = icmp eq i64 %72, -1
br i1 %73, label %74, label %76
74: ; preds = %68
%75 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.10, i64 0, i64 0))
br label %93
76: ; preds = %68
%77 = load i64, i64* %5
%78 = call i32 @read(i32 %60, i8* %33, i64 %77)
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %76
%81 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
br label %93
82: ; preds = %76
%83 = sext i32 %78 to i64
%84 = load i64, i64* %5
%85 = icmp eq i64 %84, %83
br i1 %85, label %90, label %86
86: ; preds = %82
%87 = load i32, i32* @stderr
%88 = call i32 (i32, i8*, ...) @fprintf(i32 %87, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.12, i64 0, i64 0), i64 %84, i32 %78)
%89 = call i32 @_exit(i32 1)
unreachable
90: ; preds = %82
%91 = load i8*, i8** %4
%92 = call i32 @hexdump(i8* %91, i8* %33, i64 %83)
br label %93
93: ; preds = %90, %80, %74
%94 = call i32 @close(i32 %60)
%95 = load i32, i32* @PTRACE_DETACH
%96 = load i32, i32* %3
%97 = call i32 @ptrace(i32 %95, i32 %96, i32 0, i32 0)
ret i32 0
}