#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 */
unsigned long *MAP_FAILED;
int /*<<< orphan*/ MAP_SHARED;
int /*<<< orphan*/ O_RDWR;
int PROT_READ;
int PROT_WRITE;
unsigned long atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
unsigned long *mmap(int /*<<< orphan*/, int, int, int /*<<< orphan*/, int,
                    int /*<<< orphan*/);
int munmap(unsigned long *, int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_command();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
long syscall(int, unsigned long);
int /*<<< orphan*/ usleep(int);
int main(int argc, char *argv[]) {
  int fd;
  unsigned long *map;
  unsigned long pause_clock = 0;
  char filename[1024];
  long rc;
  unsigned long step = 1;
  int replay = 1;
  if (argc != 2) {
    printf("Usage: replay_pause pid\n");
  }
  memset(filename, 0, 1024);
  sprintf(filename, "/dev/shm/uclock%s", argv[1]);
  fd = open(filename, O_RDWR);
  if (fd == -1) {
    perror("Error opening file for reading, cannot find the process");
    exit(-1);
  }
  map = mmap(0, 4096, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
  if (map == MAP_FAILED) {
    close(fd);
    perror("Error mmapping the file");
    exit(-1);
  }
  pause_clock = -1;
  while (replay) {
    char command[1024];
    printf("(replay_pause tool): ");
    scanf("%s", command);
    switch (command[0]) {
    case 'c':
    case 'n':
    case 'r': {
      printf("process running now\n");
      if (command[0] == 'n') {
        pause_clock = map[0] + step;
        printf("Next to break at %lu (step = %lu)\n", pause_clock, step);
      }
      map[1] = pause_clock;
      rc = syscall(223, atoi(argv[1]));
      if (!rc) {
        printf("Cannot wakeup sleeping process.\n");
        break;
      }
      while (1) {
        if (map[1] == 0) {
          printf("The replay is over now. Exit.\n");
          replay = 0;
          break;
        } else if (map[0] >= map[1]) {
          printf("Break at clock %lu (scheduled to break at %lu)\n", map[0],
                 map[1]);
          break;
        } else {
          usleep(100000);
        }
      }
      continue;
    } break;
    case 'b': {
      scanf("%s", command);
      pause_clock = atoi(command);
      while (pause_clock == 0) {
        printf("please enter a clock value greater than 0\n");
        pause_clock = -1;
        scanf("%s", command);
        pause_clock = atoi(command);
      }
      printf("Will break at clock %lu, now is %lu\n", pause_clock, map[0]);
      map[1] = pause_clock;
      continue;
    } break;
    case 's': {
      scanf("%s", command);
      step = atoi(command);
      printf("Step break step to %lu\n", step);
      continue;
    } break;
    case 'q': {
      printf("Exit now.\n");
      break;
    } break;
    case 'h': {
      print_command();
      continue;
    }
    default: {
      printf("Non-recognized command.\n");
      print_command();
      continue;
    }
    }
    break;
  }
  if (munmap(map, 4096) == -1) {
    perror("Error un-mmapping the file\n");
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x860,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x1,-0x440(%rbp)
movl   $0x1,-0x444(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     122e <main+0x4e>
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1060 <memset@plt>
lea    -0x430(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe0a(%rip),%rsi
call   10e0 <sprintf@plt>
lea    -0x430(%rbp),%rdi
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1294 <main+0xb4>
lea    0xdee(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
mov    0x2d5d(%rip),%rax
mov    (%rax),%edx
mov    0x2d24(%rip),%rax
or     (%rax),%edx
mov    0x2d3b(%rip),%rax
mov    (%rax),%ecx
mov    -0x14(%rbp),%r8d
xor    %r9d,%r9d
mov    $0x1000,%esi
mov    %r9d,%edi
call   1030 <mmap@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x2cee(%rip),%rcx
cmp    (%rcx),%rax
jne    12f9 <main+0x119>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
lea    0xdc1(%rip),%rdi
call   10c0 <perror@plt>
mov    $0xffffffff,%edi
call   10f0 <exit@plt>
movq   $0xffffffffffffffff,-0x28(%rbp)
cmpl   $0x0,-0x444(%rbp)
je     158e <main+0x3ae>
lea    0xdae(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd4d(%rip),%rdi
lea    -0x850(%rbp),%rsi
call   10a0 <scanf@plt>
movsbl -0x850(%rbp),%eax
add    $0xffffff9e,%eax
mov    %eax,%ecx
mov    %rcx,-0x858(%rbp)
sub    $0x11,%eax
ja     156f <main+0x38f>
mov    -0x858(%rbp),%rax
lea    0xca7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x850(%rbp),%eax
cmp    $0x6e,%eax
jne    13ab <main+0x1cb>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
add    -0x440(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rsi
mov    -0x440(%rbp),%rdx
lea    0xd4a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <atoi@plt>
mov    %rax,%rsi
mov    $0xdf,%edi
call   1080 <syscall@plt>
mov    %rax,-0x438(%rbp)
cmpq   $0x0,-0x438(%rbp)
jne    13f9 <main+0x219>
lea    0xd24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1589 <main+0x3a9>
jmp    13fe <main+0x21e>
mov    -0x20(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    142a <main+0x24a>
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x444(%rbp)
jmp    1475 <main+0x295>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x20(%rbp),%rcx
cmp    0x8(%rcx),%rax
jb     1461 <main+0x281>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xcfc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1475 <main+0x295>
mov    $0x186a0,%edi
call   1100 <usleep@plt>
jmp    1470 <main+0x290>
jmp    13fe <main+0x21e>
jmp    1301 <main+0x121>
lea    -0x850(%rbp),%rsi
lea    0xbe8(%rip),%rdi
call   10a0 <scanf@plt>
lea    -0x850(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    14e6 <main+0x306>
lea    0xcd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0xffffffffffffffff,-0x28(%rbp)
ff
lea    -0x850(%rbp),%rsi
lea    0xba4(%rip),%rdi
call   10a0 <scanf@plt>
lea    -0x850(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %rax,-0x28(%rbp)
jmp    149d <main+0x2bd>
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    (%rax),%rdx
lea    0xcb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,0x8(%rax)
jmp    1301 <main+0x121>
lea    -0x850(%rbp),%rsi
lea    0xb52(%rip),%rdi
call   10a0 <scanf@plt>
lea    -0x850(%rbp),%rdi
call   10d0 <atoi@plt>
mov    %rax,-0x440(%rbp)
mov    -0x440(%rbp),%rsi
lea    0xc8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1301 <main+0x121>
lea    0xc92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1589 <main+0x3a9>
mov    $0x0,%al
call   1050 <print_command@plt>
jmp    1301 <main+0x121>
lea    0xc7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <print_command@plt>
jmp    1301 <main+0x121>
jmp    158e <main+0x3ae>
mov    -0x20(%rbp),%rdi
mov    $0x1000,%esi
call   1090 <munmap@plt>
cmp    $0xffffffff,%eax
jne    15b1 <main+0x3d1>
lea    0xc61(%rip),%rdi
call   10c0 <perror@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x860,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x828,%rsp
mov    %rsi,0x18(%rsp)
cmp    $0x2,%edi
je     1217 <main+0x27>
lea    0xff8(%rip),%rdi
call   1030 <puts@plt>
lea    0x420(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1070 <memset@plt>
mov    0x18(%rsp),%rax
mov    0x8(%rax),%rdx
lea    0xe0a(%rip),%rsi
mov    %rbx,%rdi
call   10f0 <sprintf@plt>
mov    0x2d8b(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10c0 <open@plt>
cmp    $0xffffffff,%eax
je     14b2 <main+0x2c2>
mov    0x2d91(%rip),%rsi
mov    0x2d5a(%rip),%rcx
mov    (%rcx),%edx
or     (%rsi),%edx
mov    0x2d6f(%rip),%rcx
mov    (%rcx),%ecx
xor    %edi,%edi
mov    $0x1000,%esi
mov    %eax,0x4(%rsp)
mov    %eax,%r8d
xor    %r9d,%r9d
call   1040 <mmap@plt>
mov    %rax,%rbx
mov    0x2d25(%rip),%rax
cmp    (%rax),%rbx
je     14bb <main+0x2cb>
mov    $0xffffffffffffffff,%r13
mov    $0x1,%eax
mov    %rax,0x10(%rsp)
lea    0xd9b(%rip),%rbp
lea    0x20(%rsp),%r15
lea    0xea4(%rip),%rax
mov    %rax,0x8(%rsp)
lea    0xd2c(%rip),%r14
lea    0xe9b(%rip),%r12
lea    0xdc8(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   10b0 <scanf@plt>
movsbl 0x20(%rsp),%eax
add    $0xffffff9e,%eax
cmp    $0x11,%eax
ja     1410 <main+0x220>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
lea    0xe8b(%rip),%rdi
call   1030 <puts@plt>
cmpb   $0x6e,0x20(%rsp)
jne    133d <main+0x14d>
mov    (%rbx),%r13
mov    0x10(%rsp),%rdx
add    %rdx,%r13
lea    0xd8d(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,0x8(%rbx)
mov    0x18(%rsp),%rax
mov    0x8(%rax),%rdi
call   10e0 <atoi@plt>
mov    $0xdf,%edi
mov    %rax,%rsi
call   1090 <syscall@plt>
test   %rax,%rax
je     149f <main+0x2af>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x8(%rbx),%rdx
test   %rdx,%rdx
je     1456 <main+0x266>
mov    (%rbx),%rsi
cmp    %rdx,%rsi
jae    13a0 <main+0x1b0>
mov    $0x186a0,%edi
call   1110 <usleep@plt>
jmp    1370 <main+0x180>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xd3c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12db <main+0xeb>
mov    %rbp,%rdi
mov    %r15,%rsi
call   10b0 <scanf@plt>
mov    %r15,%rdi
call   10e0 <atoi@plt>
mov    %rax,%r13
test   %rax,%rax
jne    13f3 <main+0x203>
xchg   %ax,%ax
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
call   10b0 <scanf@plt>
mov    %r15,%rdi
call   10e0 <atoi@plt>
test   %rax,%rax
je     13d0 <main+0x1e0>
mov    %rax,%r13
mov    (%rbx),%rdx
lea    0xd16(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r13,0x8(%rbx)
jmp    12db <main+0xeb>
lea    0xddb(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1060 <print_command@plt>
jmp    12db <main+0xeb>
mov    %rbp,%rdi
mov    %r15,%rsi
call   10b0 <scanf@plt>
mov    %r15,%rdi
call   10e0 <atoi@plt>
lea    0xcf6(%rip),%rdi
mov    %rax,0x10(%rsp)
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    12db <main+0xeb>
lea    0xd77(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x1000,%esi
call   10a0 <munmap@plt>
cmp    $0xffffffff,%eax
je     1491 <main+0x2a1>
mov    0x4(%rsp),%edi
call   1080 <close@plt>
xor    %eax,%eax
add    $0x828,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcb8(%rip),%rdi
call   10d0 <perror@plt>
jmp    1474 <main+0x284>
lea    0xd0e(%rip),%rax
mov    %rax,0x8(%rsp)
mov    0x8(%rsp),%rdi
jmp    145d <main+0x26d>
lea    0xba1(%rip),%rdi
jmp    14cb <main+0x2db>
mov    0x4(%rsp),%edi
call   1080 <close@plt>
lea    0xbc7(%rip),%rdi
call   10d0 <perror@plt>
mov    $0xffffffff,%edi
call   1100 <exit@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Usage: replay_pause pid\0A\00"
@.str.1 = [18 x i8] c"/dev/shm/uclock%s\00"
@O_RDWR = global i32 0
@.str.2 = [56 x i8] c"Error opening file for reading, cannot find the process\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i64* null
@.str.3 = [24 x i8] c"Error mmapping the file\00"
@.str.4 = [22 x i8] c"(replay_pause tool): \00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [21 x i8] c"process running now\0A\00"
@.str.7 = [35 x i8] c"Next to break at %lu (step = %lu)\0A\00"
@.str.8 = [33 x i8] c"Cannot wakeup sleeping process.\0A\00"
@.str.9 = [31 x i8] c"The replay is over now. Exit.\0A\00"
@.str.10 = [48 x i8] c"Break at clock %lu (scheduled to break at %lu)\0A\00"
@.str.11 = [43 x i8] c"please enter a clock value greater than 0\0A\00"
@.str.12 = [37 x i8] c"Will break at clock %lu, now is %lu\0A\00"
@.str.13 = [24 x i8] c"Step break step to %lu\0A\00"
@.str.14 = [11 x i8] c"Exit now.\0A\00"
@.str.15 = [25 x i8] c"Non-recognized command.\0A\00"
@.str.16 = [28 x i8] c"Error un-mmapping the file\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i64*
%8 = alloca i64
%9 = alloca [1024 x i8]
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca [1024 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %8
store i64 1, i64* %11
store i32 1, i32* %12
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 2
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %2
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%20 = call i32 @memset(i8* %19, i32 0, i32 1024)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i32 @sprintf(i8* %21, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %24)
%26 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%27 = load i32, i32* @O_RDWR
%28 = call i32 @open(i8* %26, i32 %27)
store i32 %28, i32* %6
%29 = load i32, i32* %6
%30 = icmp eq i32 %29, -1
br i1 %30, label %31, label %34
31: ; preds = %18
%32 = call i32 @perror(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 @exit(i32 -1)
unreachable
34: ; preds = %18
%35 = load i32, i32* @PROT_READ
%36 = load i32, i32* @PROT_WRITE
%37 = or i32 %35, %36
%38 = load i32, i32* @MAP_SHARED
%39 = load i32, i32* %6
%40 = call i64* @mmap(i32 0, i32 4096, i32 %37, i32 %38, i32 %39, i32 0)
store i64* %40, i64** %7
%41 = load i64*, i64** %7
%42 = load i64*, i64** @MAP_FAILED
%43 = icmp eq i64* %41, %42
br i1 %43, label %44, label %49
44: ; preds = %34
%45 = load i32, i32* %6
%46 = call i32 @close(i32 %45)
%47 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%48 = call i32 @exit(i32 -1)
unreachable
49: ; preds = %34
store i64 -1, i64* %8
br label %50
50: ; preds = %151, %149, %140, %131, %116, %49
%51 = load i32, i32* %12
%52 = icmp ne i32 %51, 0
br i1 %52, label %53, label %155
53: ; preds = %50
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%56 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %55)
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
switch i32 %59, label %151 [
i32 99, label %60
i32 110, label %60
i32 114, label %60
i32 98, label %117
i32 115, label %140
i32 113, label %147
i32 104, label %149
]
60: ; preds = %53, %53, %53
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%62 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 110
br i1 %65, label %66, label %75
66: ; preds = %60
%67 = load i64*, i64** %7
%68 = getelementptr inbounds i64, i64* %67, i64 0
%69 = load i64, i64* %68
%70 = load i64, i64* %11
%71 = add i64 %69, %70
store i64 %71, i64* %8
%72 = load i64, i64* %8
%73 = load i64, i64* %11
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i64 %72, i64 %73)
br label %75
75: ; preds = %66, %60
%76 = load i64, i64* %8
%77 = load i64*, i64** %7
%78 = getelementptr inbounds i64, i64* %77, i64 1
store i64 %76, i64* %78
%79 = load i8**, i8*** %5
%80 = getelementptr inbounds i8*, i8** %79, i64 1
%81 = load i8*, i8** %80
%82 = call i64 @atoi(i8* %81)
%83 = call i64 @syscall(i32 223, i64 %82)
store i64 %83, i64* %10
%84 = load i64, i64* %10
%85 = icmp ne i64 %84, 0
br i1 %85, label %88, label %86
86: ; preds = %75
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.8, i64 0, i64 0))
br label %154
88: ; preds = %75
br label %89
89: ; preds = %88, %115
%90 = load i64*, i64** %7
%91 = getelementptr inbounds i64, i64* %90, i64 1
%92 = load i64, i64* %91
%93 = icmp eq i64 %92, 0
br i1 %93, label %94, label %96
94: ; preds = %89
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %12
br label %116
96: ; preds = %89
%97 = load i64*, i64** %7
%98 = getelementptr inbounds i64, i64* %97, i64 0
%99 = load i64, i64* %98
%100 = load i64*, i64** %7
%101 = getelementptr inbounds i64, i64* %100, i64 1
%102 = load i64, i64* %101
%103 = icmp uge i64 %99, %102
br i1 %103, label %104, label %112
104: ; preds = %96
%105 = load i64*, i64** %7
%106 = getelementptr inbounds i64, i64* %105, i64 0
%107 = load i64, i64* %106
%108 = load i64*, i64** %7
%109 = getelementptr inbounds i64, i64* %108, i64 1
%110 = load i64, i64* %109
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0), i64 %107, i64 %110)
br label %116
112: ; preds = %96
%113 = call i32 @usleep(i32 100000)
br label %114
114: ; preds = %112
br label %115
115: ; preds = %114
br label %89
116: ; preds = %104, %94
br label %50
117: ; preds = %53
%118 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%119 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %118)
%120 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%121 = call i64 @atoi(i8* %120)
store i64 %121, i64* %8
br label %122
122: ; preds = %125, %117
%123 = load i64, i64* %8
%124 = icmp eq i64 %123, 0
br i1 %124, label %125, label %131
125: ; preds = %122
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.11, i64 0, i64 0))
store i64 -1, i64* %8
%127 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%128 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %127)
%129 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%130 = call i64 @atoi(i8* %129)
store i64 %130, i64* %8
br label %122
131: ; preds = %122
%132 = load i64, i64* %8
%133 = load i64*, i64** %7
%134 = getelementptr inbounds i64, i64* %133, i64 0
%135 = load i64, i64* %134
%136 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0), i64 %132, i64 %135)
%137 = load i64, i64* %8
%138 = load i64*, i64** %7
%139 = getelementptr inbounds i64, i64* %138, i64 1
store i64 %137, i64* %139
br label %50
140: ; preds = %53
%141 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%142 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %141)
%143 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%144 = call i64 @atoi(i8* %143)
store i64 %144, i64* %11
%145 = load i64, i64* %11
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i64 %145)
br label %50
147: ; preds = %53
%148 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.14, i64 0, i64 0))
br label %154
149: ; preds = %53
%150 = call i32 (...) @print_command()
br label %50
151: ; preds = %53
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.15, i64 0, i64 0))
%153 = call i32 (...) @print_command()
br label %50
154: ; preds = %147, %86
br label %155
155: ; preds = %154, %50
%156 = load i64*, i64** %7
%157 = call i32 @munmap(i64* %156, i32 4096)
%158 = icmp eq i32 %157, -1
br i1 %158, label %159, label %161
159: ; preds = %155
%160 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0))
br label %161
161: ; preds = %159, %155
%162 = load i32, i32* %6
%163 = call i32 @close(i32 %162)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [18 x i8] c"/dev/shm/uclock%s\00"
@O_RDWR = global i32 0
@.str.2 = [56 x i8] c"Error opening file for reading, cannot find the process\00"
@PROT_READ = global i32 0
@PROT_WRITE = global i32 0
@MAP_SHARED = global i32 0
@MAP_FAILED = global i64* null
@.str.3 = [24 x i8] c"Error mmapping the file\00"
@.str.4 = [22 x i8] c"(replay_pause tool): \00"
@.str.5 = [3 x i8] c"%s\00"
@.str.7 = [35 x i8] c"Next to break at %lu (step = %lu)\0A\00"
@.str.10 = [48 x i8] c"Break at clock %lu (scheduled to break at %lu)\0A\00"
@.str.12 = [37 x i8] c"Will break at clock %lu, now is %lu\0A\00"
@.str.13 = [24 x i8] c"Step break step to %lu\0A\00"
@.str.16 = [28 x i8] c"Error un-mmapping the file\0A\00"
@str = [10 x i8] c"Exit now.\00"
@str.17 = [42 x i8] c"please enter a clock value greater than 0\00"
@str.18 = [20 x i8] c"process running now\00"
@str.19 = [32 x i8] c"Cannot wakeup sleeping process.\00"
@str.20 = [30 x i8] c"The replay is over now. Exit.\00"
@str.21 = [24 x i8] c"Non-recognized command.\00"
@str.22 = [24 x i8] c"Usage: replay_pause pid\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = icmp eq i32 %0, 2
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.22, i64 0, i64 0))
br label %9
9: ; preds = %7, %2
%10 = call i32 @memset(i8* %5, i32 0, i32 1024)
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @O_RDWR
%15 = call i32 @open(i8* %5, i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %9
%18 = call i32 @perror(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %9
%21 = load i32, i32* @PROT_READ
%22 = load i32, i32* @PROT_WRITE
%23 = or i32 %22, %21
%24 = load i32, i32* @MAP_SHARED
%25 = call i64* @mmap(i32 0, i32 4096, i32 %23, i32 %24, i32 %15, i32 0)
%26 = load i64*, i64** @MAP_FAILED
%27 = icmp eq i64* %25, %26
br i1 %27, label %31, label %28
28: ; preds = %20
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%30 = getelementptr inbounds i64, i64* %25, i64 1
br label %35
31: ; preds = %20
%32 = call i32 @close(i32 %15)
%33 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%34 = call i32 @exit(i32 -1)
unreachable
35: ; preds = %94, %28
%36 = phi i64 [ 1, %28 ], [ %96, %94 ]
%37 = phi i64 [ -1, %28 ], [ %95, %94 ]
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
%39 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%40 = load i8, i8* %29
%41 = sext i8 %40 to i32
switch i32 %41, label %88 [
i32 99, label %42
i32 110, label %42
i32 114, label %42
i32 98, label %69
i32 115, label %82
i32 113, label %91
i32 104, label %86
]
42: ; preds = %35, %35, %35
%43 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.18, i64 0, i64 0))
%44 = load i8, i8* %29
%45 = icmp eq i8 %44, 110
br i1 %45, label %46, label %50
46: ; preds = %42
%47 = load i64, i64* %25
%48 = add i64 %47, %36
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.7, i64 0, i64 0), i64 %48, i64 %36)
br label %50
50: ; preds = %46, %42
%51 = phi i64 [ %48, %46 ], [ %37, %42 ]
store i64 %51, i64* %30
%52 = load i8*, i8** %11
%53 = call i64 @atoi(i8* %52)
%54 = call i64 @syscall(i32 223, i64 %53)
%55 = icmp eq i64 %54, 0
br i1 %55, label %91, label %56
56: ; preds = %50
%57 = load i64, i64* %30
%58 = icmp eq i64 %57, 0
br i1 %58, label %97, label %59
59: ; preds = %56, %65
%60 = phi i64 [ %67, %65 ], [ %57, %56 ]
%61 = load i64, i64* %25
%62 = icmp ult i64 %61, %60
br i1 %62, label %65, label %63
63: ; preds = %59
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.10, i64 0, i64 0), i64 %61, i64 %60)
br label %94
65: ; preds = %59
%66 = call i32 @usleep(i32 100000)
%67 = load i64, i64* %30
%68 = icmp eq i64 %67, 0
br i1 %68, label %97, label %59
69: ; preds = %35
%70 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%71 = call i64 @atoi(i8* %29)
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %78
73: ; preds = %69, %73
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.17, i64 0, i64 0))
%75 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%76 = call i64 @atoi(i8* %29)
%77 = icmp eq i64 %76, 0
br i1 %77, label %73, label %78
78: ; preds = %73, %69
%79 = phi i64 [ %71, %69 ], [ %76, %73 ]
%80 = load i64, i64* %25
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.12, i64 0, i64 0), i64 %79, i64 %80)
store i64 %79, i64* %30
br label %94
82: ; preds = %35
%83 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%84 = call i64 @atoi(i8* %29)
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.13, i64 0, i64 0), i64 %84)
br label %94
86: ; preds = %35
%87 = call i32 (...) @print_command()
br label %94
88: ; preds = %35
%89 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str.21, i64 0, i64 0))
%90 = call i32 (...) @print_command()
br label %94
91: ; preds = %35, %50
%92 = phi i8* [ getelementptr inbounds ([32 x i8], [32 x i8]* @str.19, i64 0, i64 0), %50 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0), %35 ]
%93 = call i32 @puts(i8* dereferenceable(1) %92)
br label %99
94: ; preds = %63, %88, %86, %82, %78
%95 = phi i64 [ %37, %88 ], [ %37, %86 ], [ %37, %82 ], [ %79, %78 ], [ %51, %63 ]
%96 = phi i64 [ %36, %88 ], [ %36, %86 ], [ %84, %82 ], [ %36, %78 ], [ %36, %63 ]
br label %35
97: ; preds = %56, %65
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.20, i64 0, i64 0))
br label %99
99: ; preds = %97, %91
%100 = call i32 @munmap(i64* %25, i32 4096)
%101 = icmp eq i32 %100, -1
br i1 %101, label %102, label %104
102: ; preds = %99
%103 = call i32 @perror(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.16, i64 0, i64 0))
br label %104
104: ; preds = %102, %99
%105 = call i32 @close(i32 %15)
ret i32 0
}