#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 */
struct option {
  char *member_0;
  int /*<<< orphan*/ member_3;
  int /*<<< orphan*/ member_2;
  int /*<<< orphan*/ member_1;
};
typedef int pid_t;
typedef int loff_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int atoi(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
char getopt_long(int, char **, char *, struct option *, int *);
int getpid();
int open(char *, int /*<<< orphan*/);
char *optarg;
int optind;
int /*<<< orphan*/ optional_argument;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_help(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ required_argument;
int resume_after_ckpt(int, int, int, int, int, char *, char *, char *, int,
                      int);
int resume_with_ckpt(int, int, int, int, int, char *, char *, int, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int sscanf(char *, char *, int *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int main(int argc, char *argv[]) {
  int fd, rc, attach_pin = 0, attach_gdb = 0;
  loff_t attach_index = -1;
  int attach_pid = -1;
  char *libdir = NULL;
  pid_t pid;
  char ldpath[4096];
  int base;
  int follow_splits = 0;
  int save_mmap = 0;
  int ckpt_at = 0;
  int from_ckpt = 0;
  char filename[4096];
  struct option long_options[] = {{"pthread", required_argument, 0, 0},
                                  {"attach_pin_later", optional_argument, 0, 0},
                                  {"attach_offset", optional_argument, 0, 0},
                                  {"ckpt_at", required_argument, 0, 0},
                                  {"from_ckpt", required_argument, 0, 0},
                                  {0, 0, 0, 0}};
  while (1) {
    char opt;
    int option_index = 0;
    opt = getopt_long(argc, argv, "fpmhg", long_options, &option_index);
    if (opt == -1) {
      break;
    }
    switch (opt) {
    case 0:
      switch (option_index) {
      case 0:
        printf("pthread libdir is %s\n", optarg);
        libdir = optarg;
        break;
      case 1:
      case 2:
        if (sscanf(optarg, "%d,%lld", &attach_pid, &attach_index) != 2) {
          fprintf(stderr,
                  "ERROR: expected format: --attach_offset <pid>,<sysnum>\n");
          exit(EXIT_FAILURE);
        }
        break;
      case 3:
        ckpt_at = atoi(optarg);
        printf("Checkpointing at %d\n", ckpt_at);
        break;
      case 4:
        from_ckpt = atoi(optarg);
        break;
      default:
        assert(0);
      }
      break;
    case 'm':
      save_mmap = 1;
      break;
    case 'f':
      follow_splits = 1;
      break;
    case 'p':
      printf("attach_pin is on\n");
      attach_pin = 1;
      break;
    case 'h':
      print_help(argv[0]);
      exit(EXIT_SUCCESS);
      break;
    case 'g':
      printf("attach_gdb is on\n");
      attach_gdb = 1;
      break;
    default:
      fprintf(stderr, "Unrecognized option\n");
      print_help(argv[0]);
      exit(EXIT_FAILURE);
      break;
    }
  }
  base = optind;
  printf("argc = %d, base = %d\n", argc, base);
  if (argc - base != 1) {
    fprintf(stderr, "Invalid non-arg arguments!\n");
    print_help(argv[0]);
    exit(EXIT_FAILURE);
  }
  if (attach_pin && save_mmap) {
    fprintf(stderr, "Attaching pin (-p) and saving mmaps (-m) shouldn't both "
                    "be enabled!\n");
    exit(EXIT_FAILURE);
  }
  if (attach_pin && attach_gdb) {
    fprintf(stderr, "Cannot attach both pin (-p) and gdb (-g).\n");
    exit(EXIT_FAILURE);
  }
  if (libdir) {
    strcpy(ldpath, libdir);
    strcat(ldpath, "/ld-linux.so.2");
    libdir = ldpath;
  }
  fd = open("/dev/spec0", O_RDWR);
  if (fd < 0) {
    perror("open /dev/spec0");
    exit(EXIT_FAILURE);
  }
  pid = getpid();
  printf("libdir: %s, ldpath: %s\n", libdir, ldpath);
  printf("resume pid %d follow %d\n", pid, follow_splits);
  printf("resume(%d, %d, %d, %d, %s, %s, %lld, %d)\n", fd, attach_pin,
         follow_splits, save_mmap, argv[base], libdir, attach_index,
         attach_pid);
  if (from_ckpt > 0) {
    sprintf(filename, "ckpt.%d", from_ckpt);
    printf("resuming from ckpt %s\n", filename);
    rc = resume_after_ckpt(fd, attach_pin, attach_gdb, follow_splits, save_mmap,
                           argv[base], libdir, filename, attach_index,
                           attach_pid);
  } else {
    rc =
        resume_with_ckpt(fd, attach_pin, attach_gdb, follow_splits, save_mmap,
                         argv[base], libdir, attach_index, attach_pid, ckpt_at);
  }
  if (rc < 0) {
    perror("resume");
    return -1;
  }
  fprintf(stderr, "resume should not return\n");
  return -1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x2128,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0xffffffff,-0x2c(%rbp)
movl   $0xffffffff,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x1048(%rbp)
movl   $0x0,-0x104c(%rbp)
movl   $0x0,-0x1050(%rbp)
movl   $0x0,-0x1054(%rbp)
lea    -0x20f0(%rbp),%rdi
lea    0xd90(%rip),%rax
mov    %rax,-0x20f0(%rbp)
mov    0x2d36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20e8(%rbp)
movl   $0x0,-0x20e4(%rbp)
movl   $0x0,-0x20e0(%rbp)
add    $0x18,%rdi
lea    0xd63(%rip),%rax
mov    %rax,-0x20d8(%rbp)
mov    0x2d11(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20d0(%rbp)
movl   $0x0,-0x20cc(%rbp)
movl   $0x0,-0x20c8(%rbp)
add    $0x18,%rdi
lea    0xd3f(%rip),%rax
mov    %rax,-0x20c0(%rbp)
mov    0x2cdc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20b8(%rbp)
movl   $0x0,-0x20b4(%rbp)
movl   $0x0,-0x20b0(%rbp)
add    $0x18,%rdi
lea    0xd18(%rip),%rax
mov    %rax,-0x20a8(%rbp)
mov    0x2c97(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20a0(%rbp)
movl   $0x0,-0x209c(%rbp)
movl   $0x0,-0x2098(%rbp)
add    $0x18,%rdi
lea    0xceb(%rip),%rax
mov    %rax,-0x2090(%rbp)
mov    0x2c62(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2088(%rbp)
movl   $0x0,-0x2084(%rbp)
movl   $0x0,-0x2080(%rbp)
add    $0x18,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1090 <memset@plt>
movl   $0x0,-0x20f8(%rbp)
mov    -0x10(%rbp),%edi
mov    -0x18(%rbp),%rsi
lea    -0x20f0(%rbp),%rcx
lea    0xc9c(%rip),%rdx
lea    -0x20f8(%rbp),%r8
call   1060 <getopt_long@plt>
mov    %al,-0x20f1(%rbp)
movsbl -0x20f1(%rbp),%eax
cmp    $0xffffffff,%eax
jne    13d8 <main+0x1c8>
jmp    15f2 <main+0x3e2>
movsbl -0x20f1(%rbp),%eax
mov    %eax,-0x20fc(%rbp)
test   %eax,%eax
je     1456 <main+0x246>
jmp    13f2 <main+0x1e2>
mov    -0x20fc(%rbp),%eax
sub    $0x66,%eax
je     1561 <main+0x351>
jmp    1406 <main+0x1f6>
mov    -0x20fc(%rbp),%eax
sub    $0x67,%eax
je     15a4 <main+0x394>
jmp    141a <main+0x20a>
mov    -0x20fc(%rbp),%eax
sub    $0x68,%eax
je     158a <main+0x37a>
jmp    142e <main+0x21e>
mov    -0x20fc(%rbp),%eax
sub    $0x6d,%eax
je     1552 <main+0x342>
jmp    1442 <main+0x232>
mov    -0x20fc(%rbp),%eax
sub    $0x70,%eax
je     1570 <main+0x360>
jmp    15be <main+0x3ae>
mov    -0x20f8(%rbp),%eax
mov    %rax,-0x2108(%rbp)
sub    $0x4,%rax
ja     1546 <main+0x336>
mov    -0x2108(%rbp),%rax
lea    0xb85(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2b6d(%rip),%rax
mov    (%rax),%rsi
lea    0xbbe(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2b55(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
jmp    154d <main+0x33d>
mov    0x2b42(%rip),%rax
mov    (%rax),%rdi
lea    0xba9(%rip),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x2c(%rbp),%rcx
call   10c0 <sscanf@plt>
cmp    $0x2,%eax
je     14f9 <main+0x2e9>
mov    0x2adb(%rip),%rax
mov    (%rax),%edi
lea    0xb8b(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2abe(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
jmp    154d <main+0x33d>
mov    0x2af3(%rip),%rax
mov    (%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x1050(%rbp)
mov    -0x1050(%rbp),%esi
lea    0xb89(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
jmp    154d <main+0x33d>
mov    0x2ac5(%rip),%rax
mov    (%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,-0x1054(%rbp)
jmp    154d <main+0x33d>
xor    %edi,%edi
call   10a0 <assert@plt>
jmp    15ed <main+0x3dd>
movl   $0x1,-0x104c(%rbp)
jmp    15ed <main+0x3dd>
movl   $0x1,-0x1048(%rbp)
jmp    15ed <main+0x3dd>
lea    0xb47(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x24(%rbp)
jmp    15ed <main+0x3dd>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_help@plt>
mov    0x2a0b(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
lea    0xb25(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movl   $0x1,-0x28(%rbp)
jmp    15ed <main+0x3dd>
mov    0x29f3(%rip),%rax
mov    (%rax),%edi
lea    0xb14(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_help@plt>
mov    0x29ca(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
jmp    1392 <main+0x182>
mov    0x29d7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1044(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x1044(%rbp),%edx
lea    0xae6(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x10(%rbp),%eax
sub    -0x1044(%rbp),%eax
cmp    $0x1,%eax
je     1659 <main+0x449>
mov    0x2987(%rip),%rax
mov    (%rax),%edi
lea    0xad3(%rip),%rsi
call   10b0 <fprintf@plt>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1100 <print_help@plt>
mov    0x295e(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
je     1693 <main+0x483>
cmpl   $0x0,-0x104c(%rbp)
je     1693 <main+0x483>
mov    0x2941(%rip),%rax
mov    (%rax),%edi
lea    0xaa9(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x2924(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
je     16ca <main+0x4ba>
cmpl   $0x0,-0x28(%rbp)
je     16ca <main+0x4ba>
mov    0x290a(%rip),%rax
mov    (%rax),%edi
lea    0xab7(%rip),%rsi
call   10b0 <fprintf@plt>
mov    0x28ed(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
cmpq   $0x0,-0x38(%rbp)
je     1703 <main+0x4f3>
lea    -0x1040(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x1040(%rbp),%rdi
lea    0xaa6(%rip),%rsi
call   1110 <strcat@plt>
lea    -0x1040(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x28d6(%rip),%rax
mov    (%rax),%esi
lea    0xa9a(%rip),%rdi
call   10d0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    173f <main+0x52f>
lea    0xa7c(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2878(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rsi
lea    -0x1040(%rbp),%rdx
lea    0xa5d(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x3c(%rbp),%esi
mov    -0x1048(%rbp),%edx
lea    0xa5e(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x1048(%rbp),%ecx
mov    -0x104c(%rbp),%r8d
mov    -0x18(%rbp),%rax
movslq -0x1044(%rbp),%rdi
mov    (%rax,%rdi,8),%r9
mov    -0x38(%rbp),%r11
mov    -0x2c(%rbp),%r10d
mov    -0x30(%rbp),%eax
lea    0xa3c(%rip),%rdi
mov    %r11,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
mov    $0x0,%al
call   1070 <printf@plt>
cmpl   $0x0,-0x1054(%rbp)
jle    1852 <main+0x642>
lea    -0x2060(%rbp),%rdi
mov    -0x1054(%rbp),%edx
lea    0xa31(%rip),%rsi
call   1120 <sprintf@plt>
lea    -0x2060(%rbp),%rsi
lea    0xa26(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x1048(%rbp),%ecx
mov    -0x104c(%rbp),%r8d
mov    -0x18(%rbp),%rax
movslq -0x1044(%rbp),%r9
mov    (%rax,%r9,8),%r9
mov    -0x38(%rbp),%rbx
lea    -0x2060(%rbp),%r11
mov    -0x2c(%rbp),%r10d
mov    -0x30(%rbp),%eax
mov    %rbx,(%rsp)
mov    %r11,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1050 <resume_after_ckpt@plt>
mov    %eax,-0x20(%rbp)
jmp    18a3 <main+0x693>
mov    -0x1c(%rbp),%edi
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x1048(%rbp),%ecx
mov    -0x104c(%rbp),%r8d
mov    -0x18(%rbp),%rax
movslq -0x1044(%rbp),%r9
mov    (%rax,%r9,8),%r9
mov    -0x38(%rbp),%rbx
mov    -0x2c(%rbp),%r11d
mov    -0x30(%rbp),%r10d
mov    -0x1050(%rbp),%eax
mov    %rbx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1080 <resume_with_ckpt@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jge    18c5 <main+0x6b5>
lea    0x97e(%rip),%rdi
call   10e0 <perror@plt>
movl   $0xffffffff,-0xc(%rbp)
jmp    18e1 <main+0x6d1>
mov    0x26ec(%rip),%rax
mov    (%rax),%edi
lea    0x964(%rip),%rsi
call   10b0 <fprintf@plt>
movl   $0xffffffff,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x2128,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20d8,%rsp
mov    %rsi,%rbx
mov    %edi,%r13d
movl   $0xffffffff,0xc(%rsp)
ff
movl   $0xffffffff,0x8(%rsp)
ff
lea    0xe02(%rip),%rax
mov    %rax,0x40(%rsp)
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x48(%rsp)
movq   $0x0,0x4c(%rsp)
lea    0xde8(%rip),%rcx
mov    %rcx,0x58(%rsp)
mov    0x2d6c(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,0x60(%rsp)
movq   $0x0,0x64(%rsp)
lea    0xdd7(%rip),%rdx
mov    %rdx,0x70(%rsp)
mov    %ecx,0x78(%rsp)
movq   $0x0,0x7c(%rsp)
lea    0xdcc(%rip),%rcx
mov    %rcx,0x88(%rsp)
mov    %eax,0x90(%rsp)
movq   $0x0,0x94(%rsp)
lea    0xdb2(%rip),%rcx
mov    %rcx,0xa0(%rsp)
mov    %eax,0xa8(%rsp)
movq   $0x0,0xac(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0xb8(%rsp)
movq   $0x0,0xc8(%rsp)
movl   $0x0,0xd0(%rsp)
lea    0xd78(%rip),%rdx
lea    0x40(%rsp),%rcx
lea    0xd0(%rsp),%r8
call   1070 <getopt_long@plt>
cmp    $0xff,%al
je     14b3 <main+0x2a3>
lea    0xd0(%rsp),%rbp
lea    0xcd6(%rip),%r15
movl   $0x0,0x10(%rsp)
xor    %ecx,%ecx
mov    %rcx,0x28(%rsp)
xor    %r14d,%r14d
movl   $0x0,0x14(%rsp)
movl   $0x0,0x4(%rsp)
xor    %ecx,%ecx
mov    %rcx,0x18(%rsp)
xor    %ecx,%ecx
mov    %rcx,0x20(%rsp)
jmp    13a5 <main+0x195>
lea    0xef8(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
mov    %rax,0x20(%rsp)
mov    %r14d,%r12d
movl   $0x0,0xd0(%rsp)
mov    %r13d,%edi
mov    %rbx,%rsi
lea    0xcec(%rip),%rdx
lea    0x40(%rsp),%rcx
mov    %rbp,%r8
call   1070 <getopt_long@plt>
mov    %r12d,%r14d
cmp    $0xff,%al
je     14e3 <main+0x2d3>
movsbl %al,%ecx
lea    -0x66(%rcx),%eax
cmp    $0xa,%eax
ja     13d0 <main+0x1c0>
mov    $0x1,%r12d
movslq (%r15,%rax,4),%rax
add    %r15,%rax
jmp    *%rax
movl   $0x1,0x14(%rsp)
jmp    1372 <main+0x162>
nopl   0x0(%rax)
test   %ecx,%ecx
jne    16e4 <main+0x4d4>
mov    0xd0(%rsp),%eax
cmp    $0x4,%rax
ja     143f <main+0x22f>
lea    0xc40(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2bfc(%rip),%rax
mov    (%rax),%rdi
lea    0xc8f(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0xc(%rsp),%rcx
call   10c0 <sscanf@plt>
mov    %r14d,%r12d
cmp    $0x2,%eax
je     1375 <main+0x165>
jmp    1719 <main+0x509>
lea    0xe3f(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,0x4(%rsp)
jmp    1372 <main+0x162>
xor    %edi,%edi
call   10a0 <assert@plt>
jmp    1372 <main+0x162>
mov    0x2ba6(%rip),%r12
mov    (%r12),%rsi
lea    0xc22(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    (%r12),%rax
mov    %rax,0x18(%rsp)
jmp    1372 <main+0x162>
mov    0x2b7f(%rip),%rax
mov    (%rax),%rdi
call   10f0 <atoi@plt>
lea    0xc4d(%rip),%rdi
mov    %rax,0x28(%rsp)
mov    %eax,%esi
xor    %eax,%eax
call   1080 <printf@plt>
jmp    1372 <main+0x162>
mov    0x2b56(%rip),%rax
mov    (%rax),%rdi
call   10f0 <atoi@plt>
mov    %eax,0x10(%rsp)
jmp    1372 <main+0x162>
xor    %eax,%eax
mov    %rax,0x20(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
movl   $0x0,0x4(%rsp)
movl   $0x0,0x14(%rsp)
xor    %r12d,%r12d
xor    %eax,%eax
mov    %rax,0x28(%rsp)
movl   $0x0,0x10(%rsp)
mov    0x2ae6(%rip),%rax
mov    (%rax),%ebp
lea    0xc0c(%rip),%rdi
mov    %r13d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1080 <printf@plt>
sub    %ebp,%r13d
cmp    $0x1,%r13d
jne    172b <main+0x51b>
mov    0x4(%rsp),%eax
test   %eax,%eax
lea    0xd0(%rsp),%r14
je     1525 <main+0x315>
test   %r12d,%r12d
jne    173d <main+0x52d>
test   %eax,%eax
je     1534 <main+0x324>
cmpl   $0x0,0x20(%rsp)
jne    174f <main+0x53f>
mov    0x18(%rsp),%rsi
test   %rsi,%rsi
je     1557 <main+0x347>
mov    %r14,%rdi
call   1030 <strcpy@plt>
lea    0xc54(%rip),%rsi
mov    %r14,%rdi
call   1110 <strcat@plt>
jmp    155a <main+0x34a>
xor    %r14d,%r14d
mov    0x2a7f(%rip),%rax
mov    (%rax),%esi
lea    0xc4b(%rip),%rdi
call   10d0 <open@plt>
mov    %eax,0x18(%rsp)
test   %eax,%eax
js     1766 <main+0x556>
movslq %ebp,%r15
xor    %eax,%eax
call   1050 <getpid@plt>
mov    %eax,%ebp
lea    0xc32(%rip),%rdi
lea    0xd0(%rsp),%rdx
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc31(%rip),%rdi
mov    %ebp,%esi
mov    0x14(%rsp),%r13d
mov    %r13d,%edx
xor    %eax,%eax
call   1080 <printf@plt>
mov    %r15,0x38(%rsp)
mov    (%rbx,%r15,8),%r9
mov    0xc(%rsp),%r10d
mov    0x8(%rsp),%ebp
sub    $0x8,%rsp
lea    0xc1c(%rip),%rdi
mov    0x20(%rsp),%r15d
mov    %r15d,%esi
mov    %rbx,0x38(%rsp)
mov    %r14,%rbx
mov    0xc(%rsp),%r14d
mov    %r14d,%edx
mov    %r13d,%ecx
mov    %r12d,%r8d
xor    %eax,%eax
push   %rbp
push   %r10
mov    %rbx,%rbp
push   %rbx
call   1080 <printf@plt>
add    $0x20,%rsp
mov    0x10(%rsp),%edx
test   %edx,%edx
jle    166f <main+0x45f>
lea    0xc07(%rip),%rsi
lea    0x10d0(%rsp),%rbx
mov    %rbx,%rdi
call   1120 <sprintf@plt>
lea    0xbf8(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x38(%rsp),%rax
mov    0x30(%rsp),%rcx
mov    (%rcx,%rax,8),%r9
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ebx
mov    %r15d,%edi
mov    %r14d,%esi
mov    0x20(%rsp),%rdx
mov    %r13d,%ecx
mov    %r12d,%r8d
push   %rbx
push   %rax
lea    0x10e0(%rsp),%rax
push   %rax
push   %rbp
call   1060 <resume_after_ckpt@plt>
jmp    16a2 <main+0x492>
mov    0x38(%rsp),%rax
mov    0x30(%rsp),%rcx
mov    (%rcx,%rax,8),%r9
mov    0xc(%rsp),%eax
mov    0x8(%rsp),%ebx
mov    %r15d,%edi
mov    %r14d,%esi
mov    0x20(%rsp),%rdx
mov    %r13d,%ecx
mov    %r12d,%r8d
push   0x28(%rsp)
push   %rbx
push   %rax
push   %rbp
call   1090 <resume_with_ckpt@plt>
add    $0x20,%rsp
test   %eax,%eax
js     16d6 <main+0x4c6>
mov    0x2907(%rip),%rax
mov    (%rax),%edi
lea    0xb87(%rip),%rsi
call   10b0 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x20d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb5d(%rip),%rdi
call   10e0 <perror@plt>
jmp    16bf <main+0x4af>
mov    0x28cd(%rip),%rax
mov    (%rax),%edi
lea    0x9f6(%rip),%rsi
call   10b0 <fprintf@plt>
mov    (%rbx),%rdi
call   1100 <print_help@plt>
jmp    1772 <main+0x562>
mov    (%rbx),%rdi
call   1100 <print_help@plt>
mov    0x2896(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>
mov    0x2898(%rip),%rax
mov    (%rax),%edi
lea    0x974(%rip),%rsi
jmp    175f <main+0x54f>
mov    0x2886(%rip),%rax
mov    (%rax),%edi
lea    0x9da(%rip),%rsi
jmp    16f4 <main+0x4e4>
mov    0x2874(%rip),%rax
mov    (%rax),%edi
lea    0x9e4(%rip),%rsi
jmp    175f <main+0x54f>
mov    0x2862(%rip),%rax
mov    (%rax),%edi
lea    0xa17(%rip),%rsi
call   10b0 <fprintf@plt>
jmp    1772 <main+0x562>
lea    0xa43(%rip),%rdi
call   10e0 <perror@plt>
mov    0x2837(%rip),%rax
mov    (%rax),%edi
call   1130 <exit@plt>

LLVM IR (-O0):
%struct.option = type { i8*, i32, i32, i32 }
@.str = [8 x i8] c"pthread\00"
@required_argument = global i32 0
@.str.1 = [17 x i8] c"attach_pin_later\00"
@optional_argument = global i32 0
@.str.2 = [14 x i8] c"attach_offset\00"
@.str.3 = [8 x i8] c"ckpt_at\00"
@.str.4 = [10 x i8] c"from_ckpt\00"
@.str.5 = [6 x i8] c"fpmhg\00"
@.str.6 = [22 x i8] c"pthread libdir is %s\0A\00"
@optarg = global i8* null
@.str.7 = [8 x i8] c"%d,%lld\00"
@stderr = global i32 0
@.str.8 = [56 x i8] c"ERROR: expected format: --attach_offset <pid>,<sysnum>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.9 = [21 x i8] c"Checkpointing at %d\0A\00"
@.str.10 = [18 x i8] c"attach_pin is on\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.11 = [18 x i8] c"attach_gdb is on\0A\00"
@.str.12 = [21 x i8] c"Unrecognized option\0A\00"
@optind = global i32 0
@.str.13 = [22 x i8] c"argc = %d, base = %d\0A\00"
@.str.14 = [28 x i8] c"Invalid non-arg arguments!\0A\00"
@.str.15 = [69 x i8] c"Attaching pin (-p) and saving mmaps (-m) shouldn't both be enabled!\0A\00"
@.str.16 = [43 x i8] c"Cannot attach both pin (-p) and gdb (-g).\0A\00"
@.str.17 = [15 x i8] c"/ld-linux.so.2\00"
@.str.18 = [11 x i8] c"/dev/spec0\00"
@O_RDWR = global i32 0
@.str.19 = [16 x i8] c"open /dev/spec0\00"
@.str.20 = [24 x i8] c"libdir: %s, ldpath: %s\0A\00"
@.str.21 = [25 x i8] c"resume pid %d follow %d\0A\00"
@.str.22 = [42 x i8] c"resume(%d, %d, %d, %d, %s, %s, %lld, %d)\0A\00"
@.str.23 = [8 x i8] c"ckpt.%d\00"
@.str.24 = [23 x i8] c"resuming from ckpt %s\0A\00"
@.str.25 = [7 x i8] c"resume\00"
@.str.26 = [26 x i8] c"resume should not return\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca [4096 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca [4096 x i8]
%21 = alloca [6 x %struct.option]
%22 = alloca i8
%23 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
store i32 0, i32* %9
store i32 -1, i32* %10
store i32 -1, i32* %11
store i8* null, i8** %12
store i32 0, i32* %16
store i32 0, i32* %17
store i32 0, i32* %18
store i32 0, i32* %19
%24 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %21, i64 0, i64 0
%25 = getelementptr inbounds %struct.option, %struct.option* %24, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds %struct.option, %struct.option* %24, i32 0, i32 1
%27 = load i32, i32* @required_argument
store i32 %27, i32* %26
%28 = getelementptr inbounds %struct.option, %struct.option* %24, i32 0, i32 2
store i32 0, i32* %28
%29 = getelementptr inbounds %struct.option, %struct.option* %24, i32 0, i32 3
store i32 0, i32* %29
%30 = getelementptr inbounds %struct.option, %struct.option* %24, i64 1
%31 = getelementptr inbounds %struct.option, %struct.option* %30, i32 0, i32 0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %31
%32 = getelementptr inbounds %struct.option, %struct.option* %30, i32 0, i32 1
%33 = load i32, i32* @optional_argument
store i32 %33, i32* %32
%34 = getelementptr inbounds %struct.option, %struct.option* %30, i32 0, i32 2
store i32 0, i32* %34
%35 = getelementptr inbounds %struct.option, %struct.option* %30, i32 0, i32 3
store i32 0, i32* %35
%36 = getelementptr inbounds %struct.option, %struct.option* %30, i64 1
%37 = getelementptr inbounds %struct.option, %struct.option* %36, i32 0, i32 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8** %37
%38 = getelementptr inbounds %struct.option, %struct.option* %36, i32 0, i32 1
%39 = load i32, i32* @optional_argument
store i32 %39, i32* %38
%40 = getelementptr inbounds %struct.option, %struct.option* %36, i32 0, i32 2
store i32 0, i32* %40
%41 = getelementptr inbounds %struct.option, %struct.option* %36, i32 0, i32 3
store i32 0, i32* %41
%42 = getelementptr inbounds %struct.option, %struct.option* %36, i64 1
%43 = getelementptr inbounds %struct.option, %struct.option* %42, i32 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %43
%44 = getelementptr inbounds %struct.option, %struct.option* %42, i32 0, i32 1
%45 = load i32, i32* @required_argument
store i32 %45, i32* %44
%46 = getelementptr inbounds %struct.option, %struct.option* %42, i32 0, i32 2
store i32 0, i32* %46
%47 = getelementptr inbounds %struct.option, %struct.option* %42, i32 0, i32 3
store i32 0, i32* %47
%48 = getelementptr inbounds %struct.option, %struct.option* %42, i64 1
%49 = getelementptr inbounds %struct.option, %struct.option* %48, i32 0, i32 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %49
%50 = getelementptr inbounds %struct.option, %struct.option* %48, i32 0, i32 1
%51 = load i32, i32* @required_argument
store i32 %51, i32* %50
%52 = getelementptr inbounds %struct.option, %struct.option* %48, i32 0, i32 2
store i32 0, i32* %52
%53 = getelementptr inbounds %struct.option, %struct.option* %48, i32 0, i32 3
store i32 0, i32* %53
%54 = getelementptr inbounds %struct.option, %struct.option* %48, i64 1
%55 = bitcast %struct.option* %54 to i8*
br label %56
56: ; preds = %2, %117
store i32 0, i32* %23
%57 = load i32, i32* %4
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %21, i64 0, i64 0
%60 = call signext i8 @getopt_long(i32 %57, i8** %58, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %struct.option* %59, i32* %23)
store i8 %60, i8* %22
%61 = load i8, i8* %22
%62 = sext i8 %61 to i32
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %65
64: ; preds = %56
br label %118
65: ; preds = %56
%66 = load i8, i8* %22
%67 = sext i8 %66 to i32
switch i32 %67, label %108 [
i32 0, label %68
i32 109, label %95
i32 102, label %96
i32 112, label %97
i32 104, label %99
i32 103, label %106
]
68: ; preds = %65
%69 = load i32, i32* %23
switch i32 %69, label %92 [
i32 0, label %70
i32 1, label %74
i32 2, label %74
i32 3, label %84
i32 4, label %89
]
70: ; preds = %68
%71 = load i8*, i8** @optarg
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %71)
%73 = load i8*, i8** @optarg
store i8* %73, i8** %12
br label %94
74: ; preds = %68, %68
%75 = load i8*, i8** @optarg
%76 = call i32 @sscanf(i8* %75, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32* %11, i32* %10)
%77 = icmp ne i32 %76, 2
br i1 %77, label %78, label %83
78: ; preds = %74
%79 = load i32, i32* @stderr
%80 = call i32 @fprintf(i32 %79, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0))
%81 = load i32, i32* @EXIT_FAILURE
%82 = call i32 @exit(i32 %81)
unreachable
83: ; preds = %74
br label %94
84: ; preds = %68
%85 = load i8*, i8** @optarg
%86 = call i32 @atoi(i8* %85)
store i32 %86, i32* %18
%87 = load i32, i32* %18
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i32 %87)
br label %94
89: ; preds = %68
%90 = load i8*, i8** @optarg
%91 = call i32 @atoi(i8* %90)
store i32 %91, i32* %19
br label %94
92: ; preds = %68
%93 = call i32 @assert(i32 0)
br label %94
94: ; preds = %92, %89, %84, %83, %70
br label %117
95: ; preds = %65
store i32 1, i32* %17
br label %117
96: ; preds = %65
store i32 1, i32* %16
br label %117
97: ; preds = %65
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.10, i64 0, i64 0))
store i32 1, i32* %8
br label %117
99: ; preds = %65
%100 = load i8**, i8*** %5
%101 = getelementptr inbounds i8*, i8** %100, i64 0
%102 = load i8*, i8** %101
%103 = call i32 @print_help(i8* %102)
%104 = load i32, i32* @EXIT_SUCCESS
%105 = call i32 @exit(i32 %104)
unreachable
106: ; preds = %65
%107 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.11, i64 0, i64 0))
store i32 1, i32* %9
br label %117
108: ; preds = %65
%109 = load i32, i32* @stderr
%110 = call i32 @fprintf(i32 %109, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%111 = load i8**, i8*** %5
%112 = getelementptr inbounds i8*, i8** %111, i64 0
%113 = load i8*, i8** %112
%114 = call i32 @print_help(i8* %113)
%115 = load i32, i32* @EXIT_FAILURE
%116 = call i32 @exit(i32 %115)
unreachable
117: ; preds = %106, %97, %96, %95, %94
br label %56
118: ; preds = %64
%119 = load i32, i32* @optind
store i32 %119, i32* %15
%120 = load i32, i32* %4
%121 = load i32, i32* %15
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i32 %120, i32 %121)
%123 = load i32, i32* %4
%124 = load i32, i32* %15
%125 = sub nsw i32 %123, %124
%126 = icmp ne i32 %125, 1
br i1 %126, label %127, label %136
127: ; preds = %118
%128 = load i32, i32* @stderr
%129 = call i32 @fprintf(i32 %128, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%130 = load i8**, i8*** %5
%131 = getelementptr inbounds i8*, i8** %130, i64 0
%132 = load i8*, i8** %131
%133 = call i32 @print_help(i8* %132)
%134 = load i32, i32* @EXIT_FAILURE
%135 = call i32 @exit(i32 %134)
unreachable
136: ; preds = %118
%137 = load i32, i32* %8
%138 = icmp ne i32 %137, 0
br i1 %138, label %139, label %147
139: ; preds = %136
%140 = load i32, i32* %17
%141 = icmp ne i32 %140, 0
br i1 %141, label %142, label %147
142: ; preds = %139
%143 = load i32, i32* @stderr
%144 = call i32 @fprintf(i32 %143, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.15, i64 0, i64 0))
%145 = load i32, i32* @EXIT_FAILURE
%146 = call i32 @exit(i32 %145)
unreachable
147: ; preds = %139, %136
%148 = load i32, i32* %8
%149 = icmp ne i32 %148, 0
br i1 %149, label %150, label %158
150: ; preds = %147
%151 = load i32, i32* %9
%152 = icmp ne i32 %151, 0
br i1 %152, label %153, label %158
153: ; preds = %150
%154 = load i32, i32* @stderr
%155 = call i32 @fprintf(i32 %154, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.16, i64 0, i64 0))
%156 = load i32, i32* @EXIT_FAILURE
%157 = call i32 @exit(i32 %156)
unreachable
158: ; preds = %150, %147
%159 = load i8*, i8** %12
%160 = icmp ne i8* %159, null
br i1 %160, label %161, label %168
161: ; preds = %158
%162 = getelementptr inbounds [4096 x i8], [4096 x i8]* %14, i64 0, i64 0
%163 = load i8*, i8** %12
%164 = call i32 @strcpy(i8* %162, i8* %163)
%165 = getelementptr inbounds [4096 x i8], [4096 x i8]* %14, i64 0, i64 0
%166 = call i32 @strcat(i8* %165, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
%167 = getelementptr inbounds [4096 x i8], [4096 x i8]* %14, i64 0, i64 0
store i8* %167, i8** %12
br label %168
168: ; preds = %161, %158
%169 = load i32, i32* @O_RDWR
%170 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0), i32 %169)
store i32 %170, i32* %6
%171 = load i32, i32* %6
%172 = icmp slt i32 %171, 0
br i1 %172, label %173, label %177
173: ; preds = %168
%174 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.19, i64 0, i64 0))
%175 = load i32, i32* @EXIT_FAILURE
%176 = call i32 @exit(i32 %175)
unreachable
177: ; preds = %168
%178 = call i32 (...) @getpid()
store i32 %178, i32* %13
%179 = load i8*, i8** %12
%180 = getelementptr inbounds [4096 x i8], [4096 x i8]* %14, i64 0, i64 0
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0), i8* %179, i8* %180)
%182 = load i32, i32* %13
%183 = load i32, i32* %16
%184 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i64 0, i64 0), i32 %182, i32 %183)
%185 = load i32, i32* %6
%186 = load i32, i32* %8
%187 = load i32, i32* %16
%188 = load i32, i32* %17
%189 = load i8**, i8*** %5
%190 = load i32, i32* %15
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds i8*, i8** %189, i64 %191
%193 = load i8*, i8** %192
%194 = load i8*, i8** %12
%195 = load i32, i32* %10
%196 = load i32, i32* %11
%197 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.22, i64 0, i64 0), i32 %185, i32 %186, i32 %187, i32 %188, i8* %193, i8* %194, i32 %195, i32 %196)
%198 = load i32, i32* %19
%199 = icmp sgt i32 %198, 0
br i1 %199, label %200, label %221
200: ; preds = %177
%201 = getelementptr inbounds [4096 x i8], [4096 x i8]* %20, i64 0, i64 0
%202 = load i32, i32* %19
%203 = call i32 @sprintf(i8* %201, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0), i32 %202)
%204 = getelementptr inbounds [4096 x i8], [4096 x i8]* %20, i64 0, i64 0
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.24, i64 0, i64 0), i8* %204)
%206 = load i32, i32* %6
%207 = load i32, i32* %8
%208 = load i32, i32* %9
%209 = load i32, i32* %16
%210 = load i32, i32* %17
%211 = load i8**, i8*** %5
%212 = load i32, i32* %15
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds i8*, i8** %211, i64 %213
%215 = load i8*, i8** %214
%216 = load i8*, i8** %12
%217 = getelementptr inbounds [4096 x i8], [4096 x i8]* %20, i64 0, i64 0
%218 = load i32, i32* %10
%219 = load i32, i32* %11
%220 = call i32 @resume_after_ckpt(i32 %206, i32 %207, i32 %208, i32 %209, i32 %210, i8* %215, i8* %216, i8* %217, i32 %218, i32 %219)
store i32 %220, i32* %7
br label %237
221: ; preds = %177
%222 = load i32, i32* %6
%223 = load i32, i32* %8
%224 = load i32, i32* %9
%225 = load i32, i32* %16
%226 = load i32, i32* %17
%227 = load i8**, i8*** %5
%228 = load i32, i32* %15
%229 = sext i32 %228 to i64
%230 = getelementptr inbounds i8*, i8** %227, i64 %229
%231 = load i8*, i8** %230
%232 = load i8*, i8** %12
%233 = load i32, i32* %10
%234 = load i32, i32* %11
%235 = load i32, i32* %18
%236 = call i32 @resume_with_ckpt(i32 %222, i32 %223, i32 %224, i32 %225, i32 %226, i8* %231, i8* %232, i32 %233, i32 %234, i32 %235)
store i32 %236, i32* %7
br label %237
237: ; preds = %221, %200
%238 = load i32, i32* %7
%239 = icmp slt i32 %238, 0
br i1 %239, label %240, label %242
240: ; preds = %237
%241 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.25, i64 0, i64 0))
store i32 -1, i32* %3
br label %245
242: ; preds = %237
%243 = load i32, i32* @stderr
%244 = call i32 @fprintf(i32 %243, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.26, i64 0, i64 0))
store i32 -1, i32* %3
br label %245
245: ; preds = %242, %240
%246 = load i32, i32* %3
ret i32 %246
}

LLVM IR (-O2):
%struct.option = type { i8*, i32, i32, i32 }
@.str = [8 x i8] c"pthread\00"
@required_argument = global i32 0
@.str.1 = [17 x i8] c"attach_pin_later\00"
@optional_argument = global i32 0
@.str.2 = [14 x i8] c"attach_offset\00"
@.str.3 = [8 x i8] c"ckpt_at\00"
@.str.4 = [10 x i8] c"from_ckpt\00"
@.str.5 = [6 x i8] c"fpmhg\00"
@.str.6 = [22 x i8] c"pthread libdir is %s\0A\00"
@optarg = global i8* null
@.str.7 = [8 x i8] c"%d,%lld\00"
@stderr = global i32 0
@.str.8 = [56 x i8] c"ERROR: expected format: --attach_offset <pid>,<sysnum>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.9 = [21 x i8] c"Checkpointing at %d\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.12 = [21 x i8] c"Unrecognized option\0A\00"
@optind = global i32 0
@.str.13 = [22 x i8] c"argc = %d, base = %d\0A\00"
@.str.14 = [28 x i8] c"Invalid non-arg arguments!\0A\00"
@.str.15 = [69 x i8] c"Attaching pin (-p) and saving mmaps (-m) shouldn't both be enabled!\0A\00"
@.str.16 = [43 x i8] c"Cannot attach both pin (-p) and gdb (-g).\0A\00"
@.str.17 = [15 x i8] c"/ld-linux.so.2\00"
@.str.18 = [11 x i8] c"/dev/spec0\00"
@O_RDWR = global i32 0
@.str.19 = [16 x i8] c"open /dev/spec0\00"
@.str.20 = [24 x i8] c"libdir: %s, ldpath: %s\0A\00"
@.str.21 = [25 x i8] c"resume pid %d follow %d\0A\00"
@.str.22 = [42 x i8] c"resume(%d, %d, %d, %d, %s, %s, %lld, %d)\0A\00"
@.str.23 = [8 x i8] c"ckpt.%d\00"
@.str.24 = [23 x i8] c"resuming from ckpt %s\0A\00"
@.str.25 = [7 x i8] c"resume\00"
@.str.26 = [26 x i8] c"resume should not return\0A\00"
@str = [17 x i8] c"attach_gdb is on\00"
@str.27 = [17 x i8] c"attach_pin is on\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [4096 x i8]
%6 = alloca [4096 x i8]
%7 = alloca [6 x %struct.option]
%8 = alloca i32
%9 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%10 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
%11 = getelementptr inbounds [4096 x i8], [4096 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%13 = bitcast [6 x %struct.option]* %7 to i8*
%14 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 0
%15 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 0, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8** %15
%16 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 0, i32 1
%17 = load i32, i32* @required_argument
store i32 %17, i32* %16
%18 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 0, i32 2
store i32 0, i32* %18
%19 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 0, i32 3
store i32 0, i32* %19
%20 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 1, i32 0
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8** %20
%21 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 1, i32 1
%22 = load i32, i32* @optional_argument
store i32 %22, i32* %21
%23 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 1, i32 2
store i32 0, i32* %23
%24 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 1, i32 3
store i32 0, i32* %24
%25 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 2, i32 0
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8** %25
%26 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 2, i32 1
store i32 %22, i32* %26
%27 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 2, i32 2
store i32 0, i32* %27
%28 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 2, i32 3
store i32 0, i32* %28
%29 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 3, i32 0
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %29
%30 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 3, i32 1
store i32 %17, i32* %30
%31 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 3, i32 2
store i32 0, i32* %31
%32 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 3, i32 3
store i32 0, i32* %32
%33 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 4, i32 0
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), i8** %33
%34 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 4, i32 1
store i32 %17, i32* %34
%35 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 4, i32 2
store i32 0, i32* %35
%36 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 4, i32 3
store i32 0, i32* %36
%37 = getelementptr inbounds [6 x %struct.option], [6 x %struct.option]* %7, i64 0, i64 5
%38 = bitcast %struct.option* %37 to i8*
%39 = bitcast i32* %8 to i8*
store i32 0, i32* %8
%40 = call signext i8 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %struct.option* %14, i32* %8)
%41 = icmp eq i8 %40, -1
br i1 %41, label %103, label %42
42: ; preds = %2, %93
%43 = phi i8 [ %101, %93 ], [ %40, %2 ]
%44 = phi i32 [ %100, %93 ], [ 0, %2 ]
%45 = phi i32 [ %99, %93 ], [ 0, %2 ]
%46 = phi i32 [ %98, %93 ], [ 0, %2 ]
%47 = phi i32 [ %97, %93 ], [ 0, %2 ]
%48 = phi i32 [ %96, %93 ], [ 0, %2 ]
%49 = phi i8* [ %95, %93 ], [ null, %2 ]
%50 = phi i32 [ %94, %93 ], [ 0, %2 ]
%51 = sext i8 %43 to i32
switch i32 %51, label %86 [
i32 0, label %52
i32 109, label %93
i32 102, label %76
i32 112, label %77
i32 104, label %79
i32 103, label %84
]
52: ; preds = %42
%53 = load i32, i32* %8
switch i32 %53, label %74 [
i32 0, label %54
i32 1, label %58
i32 2, label %58
i32 3, label %67
i32 4, label %71
]
54: ; preds = %52
%55 = load i8*, i8** @optarg
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %55)
%57 = load i8*, i8** @optarg
br label %93
58: ; preds = %52, %52
%59 = load i8*, i8** @optarg
%60 = call i32 @sscanf(i8* %59, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32* %4, i32* %3)
%61 = icmp eq i32 %60, 2
br i1 %61, label %93, label %62
62: ; preds = %58
%63 = load i32, i32* @stderr
%64 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.8, i64 0, i64 0))
%65 = load i32, i32* @EXIT_FAILURE
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %52
%68 = load i8*, i8** @optarg
%69 = call i32 @atoi(i8* %68)
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i32 %69)
br label %93
71: ; preds = %52
%72 = load i8*, i8** @optarg
%73 = call i32 @atoi(i8* %72)
br label %93
74: ; preds = %52
%75 = call i32 @assert(i32 0)
br label %93
76: ; preds = %42
br label %93
77: ; preds = %42
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.27, i64 0, i64 0))
br label %93
79: ; preds = %42
%80 = load i8*, i8** %1
%81 = call i32 @print_help(i8* %80)
%82 = load i32, i32* @EXIT_SUCCESS
%83 = call i32 @exit(i32 %82)
unreachable
84: ; preds = %42
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %93
86: ; preds = %42
%87 = load i32, i32* @stderr
%88 = call i32 @fprintf(i32 %87, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.12, i64 0, i64 0))
%89 = load i8*, i8** %1
%90 = call i32 @print_help(i8* %89)
%91 = load i32, i32* @EXIT_FAILURE
%92 = call i32 @exit(i32 %91)
unreachable
93: ; preds = %76, %77, %84, %58, %74, %71, %67, %54, %42
%94 = phi i32 [ 1, %84 ], [ %50, %77 ], [ %50, %76 ], [ %50, %74 ], [ %50, %71 ], [ %50, %67 ], [ %50, %58 ], [ %50, %54 ], [ %50, %42 ]
%95 = phi i8* [ %49, %84 ], [ %49, %77 ], [ %49, %76 ], [ %49, %74 ], [ %49, %71 ], [ %49, %67 ], [ %49, %58 ], [ %57, %54 ], [ %49, %42 ]
%96 = phi i32 [ %48, %84 ], [ 1, %77 ], [ %48, %76 ], [ %48, %74 ], [ %48, %71 ], [ %48, %67 ], [ %48, %58 ], [ %48, %54 ], [ %48, %42 ]
%97 = phi i32 [ %47, %84 ], [ %47, %77 ], [ 1, %76 ], [ %47, %74 ], [ %47, %71 ], [ %47, %67 ], [ %47, %58 ], [ %47, %54 ], [ %47, %42 ]
%98 = phi i32 [ %46, %84 ], [ %46, %77 ], [ %46, %76 ], [ %46, %74 ], [ %46, %71 ], [ %46, %67 ], [ %46, %58 ], [ %46, %54 ], [ 1, %42 ]
%99 = phi i32 [ %45, %84 ], [ %45, %77 ], [ %45, %76 ], [ %45, %74 ], [ %45, %71 ], [ %69, %67 ], [ %45, %58 ], [ %45, %54 ], [ %45, %42 ]
%100 = phi i32 [ %44, %84 ], [ %44, %77 ], [ %44, %76 ], [ %44, %74 ], [ %73, %71 ], [ %44, %67 ], [ %44, %58 ], [ %44, %54 ], [ %44, %42 ]
store i32 0, i32* %8
%101 = call signext i8 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), %struct.option* %14, i32* %8)
%102 = icmp eq i8 %101, -1
br i1 %102, label %103, label %42
103: ; preds = %93, %2
%104 = phi i32 [ 0, %2 ], [ %94, %93 ]
%105 = phi i8* [ null, %2 ], [ %95, %93 ]
%106 = phi i32 [ 0, %2 ], [ %96, %93 ]
%107 = phi i32 [ 0, %2 ], [ %97, %93 ]
%108 = phi i32 [ 0, %2 ], [ %98, %93 ]
%109 = phi i32 [ 0, %2 ], [ %99, %93 ]
%110 = phi i32 [ 0, %2 ], [ %100, %93 ]
%111 = load i32, i32* @optind
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i32 %0, i32 %111)
%113 = sub nsw i32 %0, %111
%114 = icmp eq i32 %113, 1
br i1 %114, label %122, label %115
115: ; preds = %103
%116 = load i32, i32* @stderr
%117 = call i32 @fprintf(i32 %116, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0))
%118 = load i8*, i8** %1
%119 = call i32 @print_help(i8* %118)
%120 = load i32, i32* @EXIT_FAILURE
%121 = call i32 @exit(i32 %120)
unreachable
122: ; preds = %103
%123 = icmp ne i32 %106, 0
%124 = icmp ne i32 %108, 0
%125 = select i1 %123, i1 %124, i1 false
br i1 %125, label %126, label %131
126: ; preds = %122
%127 = load i32, i32* @stderr
%128 = call i32 @fprintf(i32 %127, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str.15, i64 0, i64 0))
%129 = load i32, i32* @EXIT_FAILURE
%130 = call i32 @exit(i32 %129)
unreachable
131: ; preds = %122
%132 = icmp ne i32 %104, 0
%133 = select i1 %123, i1 %132, i1 false
br i1 %133, label %134, label %139
134: ; preds = %131
%135 = load i32, i32* @stderr
%136 = call i32 @fprintf(i32 %135, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.16, i64 0, i64 0))
%137 = load i32, i32* @EXIT_FAILURE
%138 = call i32 @exit(i32 %137)
unreachable
139: ; preds = %131
%140 = icmp eq i8* %105, null
br i1 %140, label %144, label %141
141: ; preds = %139
%142 = call i32 @strcpy(i8* %11, i8* %105)
%143 = call i32 @strcat(i8* %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.17, i64 0, i64 0))
br label %144
144: ; preds = %141, %139
%145 = phi i8* [ %11, %141 ], [ null, %139 ]
%146 = load i32, i32* @O_RDWR
%147 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0), i32 %146)
%148 = icmp slt i32 %147, 0
br i1 %148, label %149, label %153
149: ; preds = %144
%150 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.19, i64 0, i64 0))
%151 = load i32, i32* @EXIT_FAILURE
%152 = call i32 @exit(i32 %151)
unreachable
153: ; preds = %144
%154 = call i32 (...) @getpid()
%155 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0), i8* %145, i8* %11)
%156 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i64 0, i64 0), i32 %154, i32 %107)
%157 = sext i32 %111 to i64
%158 = getelementptr inbounds i8*, i8** %1, i64 %157
%159 = load i8*, i8** %158
%160 = load i32, i32* %3
%161 = load i32, i32* %4
%162 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.22, i64 0, i64 0), i32 %147, i32 %106, i32 %107, i32 %108, i8* %159, i8* %145, i32 %160, i32 %161)
%163 = icmp sgt i32 %110, 0
br i1 %163, label %164, label %171
164: ; preds = %153
%165 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.23, i64 0, i64 0), i32 %110)
%166 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.24, i64 0, i64 0), i8* %12)
%167 = load i8*, i8** %158
%168 = load i32, i32* %3
%169 = load i32, i32* %4
%170 = call i32 @resume_after_ckpt(i32 %147, i32 %106, i32 %104, i32 %107, i32 %108, i8* %167, i8* %145, i8* %12, i32 %168, i32 %169)
br label %176
171: ; preds = %153
%172 = load i8*, i8** %158
%173 = load i32, i32* %3
%174 = load i32, i32* %4
%175 = call i32 @resume_with_ckpt(i32 %147, i32 %106, i32 %104, i32 %107, i32 %108, i8* %172, i8* %145, i32 %173, i32 %174, i32 %109)
br label %176
176: ; preds = %171, %164
%177 = phi i32 [ %170, %164 ], [ %175, %171 ]
%178 = icmp slt i32 %177, 0
br i1 %178, label %179, label %181
179: ; preds = %176
%180 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.25, i64 0, i64 0))
br label %184
181: ; preds = %176
%182 = load i32, i32* @stderr
%183 = call i32 @fprintf(i32 %182, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.26, i64 0, i64 0))
br label %184
184: ; preds = %181, %179
ret i32 -1
}