#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 /*<<< orphan*/ cwd2;
typedef int /*<<< orphan*/ cwd1;

/* Variables and functions */
int /*<<< orphan*/ ENOENT;
int PATH_MAX;
int /*<<< orphan*/ SIGKILL;
scalar_t__ chdir(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
int fork();
scalar_t__ getcwd(char *, int);
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ pause();
int readlink(char *, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ test_daemon();
int /*<<< orphan*/ test_init(int, char **);
int /*<<< orphan*/ test_msg(char *, ...);
int /*<<< orphan*/ test_waitsig();
int /*<<< orphan*/ waitpid(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char **argv) {
  int pid, len;
  char cwd1[PATH_MAX], cwd2[PATH_MAX];
  test_init(argc, argv);
  pid = fork();
  if (pid < 0) {
    test_msg("ERR: %s:%d: "
             "fork failed"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/unhashed_proc.c",
             24, errno, strerror(errno));
    exit(1);
  } else if (!pid) {
    pause();
    return 0;
  }
  sprintf(cwd1, "/proc/%d", pid);
  if (chdir(cwd1) < 0) {
    kill(pid, SIGKILL);
    test_msg("ERR: %s:%d: "
             "chdir failed"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/unhashed_proc.c",
             35, errno, strerror(errno));
    exit(1);
  }
  kill(pid, SIGKILL);
  waitpid(pid, NULL, 0);
  if (getcwd(cwd1, sizeof(cwd1))) {
    test_msg("ERR: %s:%d: "
             "successful getcwd: %s"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/unhashed_proc.c",
             43, cwd1, errno, strerror(errno));
    exit(1);
  } else if (errno != ENOENT) {
    test_msg("ERR: %s:%d: "
             "wrong errno"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/unhashed_proc.c",
             46, errno, strerror(errno));
    exit(1);
  }
  len = readlink("/proc/self/cwd", cwd1, sizeof(cwd1));
  if (len < 0) {
    test_msg("ERR: %s:%d: "
             "can't read cwd symlink"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/unhashed_proc.c",
             52, errno, strerror(errno));
    exit(1);
  }
  cwd1[len] = 0;
  test_daemon();
  test_waitsig();
  if (getcwd(cwd2, sizeof(cwd2))) {
    test_msg("FAIL: %s:%d: "
             "successful getcwd: %s\n"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/unhashed_proc.c",
             61, cwd2, errno, strerror(errno));
    exit(1);
  } else if (errno != ENOENT) {
    test_msg("FAIL: %s:%d: "
             "wrong errno: %m\n"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/unhashed_proc.c",
             64, errno, strerror(errno));
    exit(1);
  }
  len = readlink("/proc/self/cwd", cwd2, sizeof(cwd2) - 1);
  if (len < 0) {
    test_msg("FAIL: %s:%d: "
             "can't read cwd symlink %m\n"
             " (errno = %d (%s))\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/"
             "master/test/zdtm/live/static/unhashed_proc.c",
             70, errno, strerror(errno));
    exit(1);
  }
  cwd2[len] = 0;
  if (strcmp(cwd1, cwd2))
    test_msg("cwd differs: %s != %s\n", cwd1, cwd2);
  test_msg("PASS\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2de0(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0x58(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x50(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x28(%rbp)
mov    (%rax),%eax
mov    %rax,-0x48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <test_init@plt>
mov    $0x0,%al
call   1110 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12bf <main+0xcf>
mov    0x2d56(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    0x2d4a(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x5c(%rbp),%ecx
mov    %eax,%r8d
lea    0xd5e(%rip),%rdi
lea    0xd82(%rip),%rsi
mov    $0x18,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
cmpl   $0x0,-0x14(%rbp)
jne    12e3 <main+0xf3>
mov    $0x0,%al
call   10c0 <pause@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    1645 <main+0x455>
jmp    12e8 <main+0xf8>
mov    -0x50(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xddf(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x50(%rbp),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
jge    1363 <main+0x173>
mov    -0x14(%rbp),%edi
mov    0x2cb8(%rip),%rax
mov    (%rax),%esi
call   10b0 <kill@plt>
mov    0x2cb2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x60(%rbp)
mov    0x2ca6(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x60(%rbp),%ecx
mov    %eax,%r8d
lea    0xd98(%rip),%rdi
lea    0xcde(%rip),%rsi
mov    $0x23,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x14(%rbp),%edi
mov    0x2c63(%rip),%rax
mov    (%rax),%esi
call   10b0 <kill@plt>
mov    -0x14(%rbp),%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10d0 <waitpid@plt>
mov    -0x50(%rbp),%rdi
mov    -0x58(%rbp),%rax
mov    %eax,%esi
call   1070 <getcwd@plt>
cmp    $0x0,%rax
je     13e4 <main+0x1f4>
mov    0x2c36(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    0x2c2a(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x50(%rbp),%rcx
mov    -0x64(%rbp),%r8d
mov    %eax,%r9d
lea    0xd43(%rip),%rdi
lea    0xc5d(%rip),%rsi
mov    $0x2b,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2bed(%rip),%rax
mov    (%rax),%eax
mov    0x2bcc(%rip),%rcx
cmp    (%rcx),%eax
je     1440 <main+0x250>
mov    0x2bd5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x68(%rbp)
mov    0x2bc9(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x68(%rbp),%ecx
mov    %eax,%r8d
lea    0xd1c(%rip),%rdi
lea    0xc01(%rip),%rsi
mov    $0x2e,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1445 <main+0x255>
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rax
mov    %eax,%edx
lea    0xd14(%rip),%rdi
call   1040 <readlink@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    14ac <main+0x2bc>
mov    0x2b69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x6c(%rbp)
mov    0x2b5d(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x6c(%rbp),%ecx
mov    %eax,%r8d
lea    0xcea(%rip),%rdi
lea    0xb95(%rip),%rsi
mov    $0x34,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x50(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    $0x0,%al
call   1060 <test_daemon@plt>
mov    $0x0,%al
call   1090 <test_waitsig@plt>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %eax,%esi
call   1070 <getcwd@plt>
cmp    $0x0,%rax
je     1528 <main+0x338>
mov    0x2af2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    0x2ae6(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x40(%rbp),%rcx
mov    -0x70(%rbp),%r8d
mov    %eax,%r9d
lea    0xca4(%rip),%rdi
lea    0xb19(%rip),%rsi
mov    $0x3d,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2aa9(%rip),%rax
mov    (%rax),%eax
mov    0x2a88(%rip),%rcx
cmp    (%rcx),%eax
je     1584 <main+0x394>
mov    0x2a91(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x74(%rbp)
mov    0x2a85(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x74(%rbp),%ecx
mov    %eax,%r8d
lea    0xc7f(%rip),%rdi
lea    0xabd(%rip),%rsi
mov    $0x40,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    1589 <main+0x399>
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rax
sub    $0x1,%rax
mov    %eax,%edx
lea    0xbcc(%rip),%rdi
call   1040 <readlink@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    15f4 <main+0x404>
mov    0x2a21(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x78(%rbp)
mov    0x2a15(%rip),%rax
mov    (%rax),%edi
call   1100 <strerror@plt>
mov    -0x78(%rbp),%ecx
mov    %eax,%r8d
lea    0xc40(%rip),%rdi
lea    0xa4d(%rip),%rsi
mov    $0x46,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    -0x40(%rbp),%rsi
mov    -0x50(%rbp),%rdi
movslq -0x18(%rbp),%rax
movb   $0x0,(%rsi,%rax,1)
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
je     1629 <main+0x439>
mov    -0x40(%rbp),%rdx
mov    -0x50(%rbp),%rsi
lea    0xc30(%rip),%rdi
mov    $0x0,%al
call   1080 <test_msg@plt>
lea    0xc39(%rip),%rdi
mov    $0x0,%al
call   1080 <test_msg@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x2deb(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%r13
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
call   1030 <test_init@plt>
xor    %eax,%eax
call   1110 <fork@plt>
test   %eax,%eax
js     1374 <main+0x184>
je     135c <main+0x16c>
mov    %eax,%ebx
lea    0xe90(%rip),%rsi
mov    %r13,%rdi
mov    %eax,%edx
call   10e0 <sprintf@plt>
mov    %r13,%rdi
call   1050 <chdir@plt>
mov    %rax,%r12
mov    0x2d6f(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10b0 <kill@plt>
test   %r12,%r12
js     139c <main+0x1ac>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <waitpid@plt>
mov    %r13,%rdi
mov    %r15d,%esi
call   1070 <getcwd@plt>
mov    0x2d48(%rip),%rcx
mov    (%rcx),%r12d
test   %rax,%rax
jne    13c4 <main+0x1d4>
mov    0x2d1d(%rip),%rbx
cmp    (%rbx),%r12d
jne    13e4 <main+0x1f4>
lea    0xeb7(%rip),%rdi
mov    %r13,%rsi
mov    %r15d,%edx
call   1040 <readlink@plt>
test   %eax,%eax
js     1407 <main+0x217>
mov    %eax,%eax
movb   $0x0,0x0(%r13,%rax,1)
xor    %eax,%eax
call   1060 <test_daemon@plt>
xor    %eax,%eax
call   1090 <test_waitsig@plt>
mov    %r14,%rdi
mov    %r15d,%esi
call   1070 <getcwd@plt>
mov    0x2cea(%rip),%rcx
mov    (%rcx),%r12d
test   %rax,%rax
jne    142c <main+0x23c>
cmp    (%rbx),%r12d
jne    1461 <main+0x271>
add    $0xffffffff,%r15d
lea    0xe5c(%rip),%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1040 <readlink@plt>
test   %eax,%eax
js     1481 <main+0x291>
mov    %eax,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     134c <main+0x15c>
lea    0xf13(%rip),%rdi
mov    %r13,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <test_msg@plt>
lea    0xf16(%rip),%rdi
xor    %eax,%eax
call   1080 <test_msg@plt>
jmp    1363 <main+0x173>
xor    %eax,%eax
call   10c0 <pause@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c5d(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1100 <strerror@plt>
lea    0xc75(%rip),%rdi
lea    0xc99(%rip),%rsi
mov    $0x18,%edx
jmp    14a4 <main+0x2b4>
mov    0x2c35(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1100 <strerror@plt>
lea    0xd2b(%rip),%rdi
lea    0xc71(%rip),%rsi
mov    $0x23,%edx
jmp    14a4 <main+0x2b4>
mov    %r12d,%edi
call   1100 <strerror@plt>
lea    0xd37(%rip),%rdi
lea    0xc51(%rip),%rsi
mov    $0x2b,%edx
mov    %r13,%rcx
jmp    144a <main+0x25a>
mov    %r12d,%edi
call   1100 <strerror@plt>
lea    0xd4c(%rip),%rdi
lea    0xc31(%rip),%rsi
mov    $0x2e,%edx
mov    %r12d,%ecx
jmp    14a6 <main+0x2b6>
mov    0x2bca(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1100 <strerror@plt>
lea    0xd5b(%rip),%rdi
lea    0xc06(%rip),%rsi
mov    $0x34,%edx
jmp    14a4 <main+0x2b4>
mov    %r12d,%edi
call   1100 <strerror@plt>
lea    0xd74(%rip),%rdi
lea    0xbe9(%rip),%rsi
mov    $0x3d,%edx
mov    %r14,%rcx
mov    %r12d,%r8d
mov    %eax,%r9d
xor    %eax,%eax
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    %r12d,%edi
call   1100 <strerror@plt>
lea    0xd76(%rip),%rdi
lea    0xbb4(%rip),%rsi
mov    $0x40,%edx
mov    %r12d,%ecx
jmp    14a6 <main+0x2b6>
mov    0x2b50(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%edi
call   1100 <strerror@plt>
lea    0xd7f(%rip),%rdi
lea    0xb8c(%rip),%rsi
mov    $0x46,%edx
mov    %ebx,%ecx
mov    %eax,%r8d
xor    %eax,%eax
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [43 x i8] c"ERR: %s:%d: fork failed (errno = %d (%s))\0A\00"
@.str.1 = [170 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/live/static/unhashed_proc.c\00"
@errno = global i32 0
@.str.2 = [9 x i8] c"/proc/%d\00"
@SIGKILL = global i32 0
@.str.3 = [44 x i8] c"ERR: %s:%d: chdir failed (errno = %d (%s))\0A\00"
@.str.4 = [53 x i8] c"ERR: %s:%d: successful getcwd: %s (errno = %d (%s))\0A\00"
@ENOENT = global i32 0
@.str.5 = [43 x i8] c"ERR: %s:%d: wrong errno (errno = %d (%s))\0A\00"
@.str.6 = [15 x i8] c"/proc/self/cwd\00"
@.str.7 = [54 x i8] c"ERR: %s:%d: can't read cwd symlink (errno = %d (%s))\0A\00"
@.str.8 = [55 x i8] c"FAIL: %s:%d: successful getcwd: %s\0A (errno = %d (%s))\0A\00"
@.str.9 = [49 x i8] c"FAIL: %s:%d: wrong errno: %m\0A (errno = %d (%s))\0A\00"
@.str.10 = [59 x i8] c"FAIL: %s:%d: can't read cwd symlink %m\0A (errno = %d (%s))\0A\00"
@.str.11 = [23 x i8] c"cwd differs: %s != %s\0A\00"
@.str.12 = [6 x i8] c"PASS\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 i8*
%9 = alloca i64
%10 = alloca i64
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @PATH_MAX
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %8
%15 = alloca i8, i64 %13
store i64 %13, i64* %9
%16 = load i32, i32* @PATH_MAX
%17 = zext i32 %16 to i64
%18 = alloca i8, i64 %17
store i64 %17, i64* %10
%19 = load i32, i32* %4
%20 = load i8**, i8*** %5
%21 = call i32 @test_init(i32 %19, i8** %20)
%22 = call i32 (...) @fork()
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %31
25: ; preds = %2
%26 = load i32, i32* @errno
%27 = load i32, i32* @errno
%28 = call i32 @strerror(i32 %27)
%29 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 24, i32 %26, i32 %28)
%30 = call i32 @exit(i32 1)
unreachable
31: ; preds = %2
%32 = load i32, i32* %6
%33 = icmp ne i32 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %31
%35 = call i32 (...) @pause()
store i32 0, i32* %3
store i32 1, i32* %11
br label %136
36: ; preds = %31
br label %37
37: ; preds = %36
%38 = load i32, i32* %6
%39 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = call i64 @chdir(i8* %15)
%41 = icmp slt i64 %40, 0
br i1 %41, label %42, label %51
42: ; preds = %37
%43 = load i32, i32* %6
%44 = load i32, i32* @SIGKILL
%45 = call i32 @kill(i32 %43, i32 %44)
%46 = load i32, i32* @errno
%47 = load i32, i32* @errno
%48 = call i32 @strerror(i32 %47)
%49 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 35, i32 %46, i32 %48)
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %37
%52 = load i32, i32* %6
%53 = load i32, i32* @SIGKILL
%54 = call i32 @kill(i32 %52, i32 %53)
%55 = load i32, i32* %6
%56 = call i32 @waitpid(i32 %55, i32* null, i32 0)
%57 = trunc i64 %13 to i32
%58 = call i64 @getcwd(i8* %15, i32 %57)
%59 = icmp ne i64 %58, 0
br i1 %59, label %60, label %66
60: ; preds = %51
%61 = load i32, i32* @errno
%62 = load i32, i32* @errno
%63 = call i32 @strerror(i32 %62)
%64 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 43, i8* %15, i32 %61, i32 %63)
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %51
%67 = load i32, i32* @errno
%68 = load i32, i32* @ENOENT
%69 = icmp ne i32 %67, %68
br i1 %69, label %70, label %76
70: ; preds = %66
%71 = load i32, i32* @errno
%72 = load i32, i32* @errno
%73 = call i32 @strerror(i32 %72)
%74 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 46, i32 %71, i32 %73)
%75 = call i32 @exit(i32 1)
unreachable
76: ; preds = %66
br label %77
77: ; preds = %76
%78 = trunc i64 %13 to i32
%79 = call i32 @readlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %15, i32 %78)
store i32 %79, i32* %7
%80 = load i32, i32* %7
%81 = icmp slt i32 %80, 0
br i1 %81, label %82, label %88
82: ; preds = %77
%83 = load i32, i32* @errno
%84 = load i32, i32* @errno
%85 = call i32 @strerror(i32 %84)
%86 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 52, i32 %83, i32 %85)
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %77
%89 = load i32, i32* %7
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %15, i64 %90
store i8 0, i8* %91
%92 = call i32 (...) @test_daemon()
%93 = call i32 (...) @test_waitsig()
%94 = trunc i64 %17 to i32
%95 = call i64 @getcwd(i8* %18, i32 %94)
%96 = icmp ne i64 %95, 0
br i1 %96, label %97, label %103
97: ; preds = %88
%98 = load i32, i32* @errno
%99 = load i32, i32* @errno
%100 = call i32 @strerror(i32 %99)
%101 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 61, i8* %18, i32 %98, i32 %100)
%102 = call i32 @exit(i32 1)
unreachable
103: ; preds = %88
%104 = load i32, i32* @errno
%105 = load i32, i32* @ENOENT
%106 = icmp ne i32 %104, %105
br i1 %106, label %107, label %113
107: ; preds = %103
%108 = load i32, i32* @errno
%109 = load i32, i32* @errno
%110 = call i32 @strerror(i32 %109)
%111 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 64, i32 %108, i32 %110)
%112 = call i32 @exit(i32 1)
unreachable
113: ; preds = %103
br label %114
114: ; preds = %113
%115 = sub i64 %17, 1
%116 = trunc i64 %115 to i32
%117 = call i32 @readlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %18, i32 %116)
store i32 %117, i32* %7
%118 = load i32, i32* %7
%119 = icmp slt i32 %118, 0
br i1 %119, label %120, label %126
120: ; preds = %114
%121 = load i32, i32* @errno
%122 = load i32, i32* @errno
%123 = call i32 @strerror(i32 %122)
%124 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 70, i32 %121, i32 %123)
%125 = call i32 @exit(i32 1)
unreachable
126: ; preds = %114
%127 = load i32, i32* %7
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i8, i8* %18, i64 %128
store i8 0, i8* %129
%130 = call i64 @strcmp(i8* %15, i8* %18)
%131 = icmp ne i64 %130, 0
br i1 %131, label %132, label %134
132: ; preds = %126
%133 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8* %15, i8* %18)
br label %134
134: ; preds = %132, %126
%135 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %3
store i32 1, i32* %11
br label %136
136: ; preds = %134, %34
%137 = load i8*, i8** %8
%138 = load i32, i32* %3
ret i32 %138
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [43 x i8] c"ERR: %s:%d: fork failed (errno = %d (%s))\0A\00"
@.str.1 = [170 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AuthenticEshkinKot/criu/refs/heads/master/test/zdtm/live/static/unhashed_proc.c\00"
@errno = global i32 0
@.str.2 = [9 x i8] c"/proc/%d\00"
@SIGKILL = global i32 0
@.str.3 = [44 x i8] c"ERR: %s:%d: chdir failed (errno = %d (%s))\0A\00"
@.str.4 = [53 x i8] c"ERR: %s:%d: successful getcwd: %s (errno = %d (%s))\0A\00"
@ENOENT = global i32 0
@.str.5 = [43 x i8] c"ERR: %s:%d: wrong errno (errno = %d (%s))\0A\00"
@.str.6 = [15 x i8] c"/proc/self/cwd\00"
@.str.7 = [54 x i8] c"ERR: %s:%d: can't read cwd symlink (errno = %d (%s))\0A\00"
@.str.8 = [55 x i8] c"FAIL: %s:%d: successful getcwd: %s\0A (errno = %d (%s))\0A\00"
@.str.9 = [49 x i8] c"FAIL: %s:%d: wrong errno: %m\0A (errno = %d (%s))\0A\00"
@.str.10 = [59 x i8] c"FAIL: %s:%d: can't read cwd symlink %m\0A (errno = %d (%s))\0A\00"
@.str.11 = [23 x i8] c"cwd differs: %s != %s\0A\00"
@.str.12 = [6 x i8] c"PASS\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = alloca i8, i64 %4
%7 = tail call i32 @test_init(i32 %0, i8** %1)
%8 = tail call i32 (...) @fork()
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %2
%11 = load i32, i32* @errno
%12 = tail call i32 @strerror(i32 %11)
%13 = tail call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 24, i32 %11, i32 %12)
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = icmp eq i32 %8, 0
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = tail call i32 (...) @pause()
br label %91
19: ; preds = %15
%20 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%21 = call i64 @chdir(i8* %5)
%22 = icmp slt i64 %21, 0
%23 = load i32, i32* @SIGKILL
%24 = call i32 @kill(i32 %8, i32 %23)
br i1 %22, label %25, label %30
25: ; preds = %19
%26 = load i32, i32* @errno
%27 = call i32 @strerror(i32 %26)
%28 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 35, i32 %26, i32 %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %19
%31 = call i32 @waitpid(i32 %8, i32* null, i32 0)
%32 = call i64 @getcwd(i8* %5, i32 %3)
%33 = icmp eq i64 %32, 0
%34 = load i32, i32* @errno
br i1 %33, label %39, label %35
35: ; preds = %30
%36 = call i32 @strerror(i32 %34)
%37 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 43, i8* %5, i32 %34, i32 %36)
%38 = call i32 @exit(i32 1)
unreachable
39: ; preds = %30
%40 = load i32, i32* @ENOENT
%41 = icmp eq i32 %34, %40
br i1 %41, label %46, label %42
42: ; preds = %39
%43 = call i32 @strerror(i32 %34)
%44 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 46, i32 %34, i32 %43)
%45 = call i32 @exit(i32 1)
unreachable
46: ; preds = %39
%47 = call i32 @readlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %5, i32 %3)
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %54
49: ; preds = %46
%50 = load i32, i32* @errno
%51 = call i32 @strerror(i32 %50)
%52 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 52, i32 %50, i32 %51)
%53 = call i32 @exit(i32 1)
unreachable
54: ; preds = %46
%55 = zext i32 %47 to i64
%56 = getelementptr inbounds i8, i8* %5, i64 %55
store i8 0, i8* %56
%57 = call i32 (...) @test_daemon()
%58 = call i32 (...) @test_waitsig()
%59 = call i64 @getcwd(i8* %6, i32 %3)
%60 = icmp eq i64 %59, 0
%61 = load i32, i32* @errno
br i1 %60, label %66, label %62
62: ; preds = %54
%63 = call i32 @strerror(i32 %61)
%64 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 61, i8* %6, i32 %61, i32 %63)
%65 = call i32 @exit(i32 1)
unreachable
66: ; preds = %54
%67 = load i32, i32* @ENOENT
%68 = icmp eq i32 %61, %67
br i1 %68, label %73, label %69
69: ; preds = %66
%70 = call i32 @strerror(i32 %61)
%71 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.9, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 64, i32 %61, i32 %70)
%72 = call i32 @exit(i32 1)
unreachable
73: ; preds = %66
%74 = add i32 %3, -1
%75 = call i32 @readlink(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.6, i64 0, i64 0), i8* %6, i32 %74)
%76 = icmp slt i32 %75, 0
br i1 %76, label %77, label %82
77: ; preds = %73
%78 = load i32, i32* @errno
%79 = call i32 @strerror(i32 %78)
%80 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([170 x i8], [170 x i8]* @.str.1, i64 0, i64 0), i32 70, i32 %78, i32 %79)
%81 = call i32 @exit(i32 1)
unreachable
82: ; preds = %73
%83 = zext i32 %75 to i64
%84 = getelementptr inbounds i8, i8* %6, i64 %83
store i8 0, i8* %84
%85 = call i64 @strcmp(i8* %5, i8* %6)
%86 = icmp eq i64 %85, 0
br i1 %86, label %89, label %87
87: ; preds = %82
%88 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.11, i64 0, i64 0), i8* %5, i8* %6)
br label %89
89: ; preds = %87, %82
%90 = call i32 (i8*, ...) @test_msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
br label %91
91: ; preds = %89, %17
ret i32 0
}