#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*/ 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 %m\n"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/unhashed_proc.c",
             24, 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 %m\n"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/unhashed_proc.c",
             35, errno);
    exit(1);
  }
  kill(pid, SIGKILL);
  waitpid(pid, NULL, 0);
  if (getcwd(cwd1, sizeof(cwd1))) {
    test_msg("ERR: %s:%d: "
             "successfull getcwd: %s\n"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/unhashed_proc.c",
             43, cwd1, errno);
    exit(1);
  } else if (errno != ENOENT) {
    test_msg("ERR: %s:%d: "
             "wrong errno: %m\n"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/unhashed_proc.c",
             46, errno);
    exit(1);
  }
  len = readlink("/proc/self/cwd", cwd1, sizeof(cwd1));
  if (len < 0) {
    test_msg("ERR: %s:%d: "
             "can't read cwd symlink %m\n"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/unhashed_proc.c",
             52, errno);
    exit(1);
  }
  cwd1[len] = 0;
  test_daemon();
  test_waitsig();
  if (getcwd(cwd2, sizeof(cwd2))) {
    test_msg("FAIL: %s:%d: "
             "successfull getcwd: %s\n"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/unhashed_proc.c",
             61, cwd2, errno);
    exit(1);
  } else if (errno != ENOENT) {
    test_msg("FAIL: %s:%d: "
             "wrong errno: %m\n"
             " (errno = %d)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/unhashed_proc.c",
             64, 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)\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/OSLL/pmover/refs/heads/master/test/"
             "zdtm/live/static/unhashed_proc.c",
             70, 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    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2df3(%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   1100 <fork@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1295 <main+0xb5>
mov    0x2d69(%rip),%rax
mov    (%rax),%ecx
lea    0xd88(%rip),%rdi
lea    0xdab(%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    12b9 <main+0xd9>
mov    $0x0,%al
call   10c0 <pause@plt>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x34(%rbp)
jmp    157a <main+0x39a>
jmp    12be <main+0xde>
mov    -0x50(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xdfc(%rip),%rsi
call   10e0 <sprintf@plt>
mov    -0x50(%rbp),%rdi
call   1050 <chdir@plt>
cmp    $0x0,%rax
jge    1322 <main+0x142>
mov    -0x14(%rbp),%edi
mov    0x2ce2(%rip),%rax
mov    (%rax),%esi
call   10b0 <kill@plt>
mov    0x2cdc(%rip),%rax
mov    (%rax),%ecx
lea    0xdcc(%rip),%rdi
lea    0xd1e(%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    0x2ca4(%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     138c <main+0x1ac>
mov    -0x50(%rbp),%rcx
mov    0x2c73(%rip),%rax
mov    (%rax),%r8d
lea    0xd8d(%rip),%rdi
lea    0xcb4(%rip),%rsi
mov    $0x2b,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2c45(%rip),%rax
mov    (%rax),%eax
mov    0x2c24(%rip),%rcx
cmp    (%rcx),%eax
je     13d1 <main+0x1f1>
mov    0x2c2d(%rip),%rax
mov    (%rax),%ecx
lea    0xd7a(%rip),%rdi
lea    0xc6f(%rip),%rsi
mov    $0x2e,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    13d6 <main+0x1f6>
mov    -0x50(%rbp),%rsi
mov    -0x58(%rbp),%rax
mov    %eax,%edx
lea    0xd72(%rip),%rdi
call   1040 <readlink@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1426 <main+0x246>
mov    0x2bd8(%rip),%rax
mov    (%rax),%ecx
lea    0xd5f(%rip),%rdi
lea    0xc1a(%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     148b <main+0x2ab>
mov    -0x40(%rbp),%rcx
mov    0x2b74(%rip),%rax
mov    (%rax),%r8d
lea    0xd2f(%rip),%rdi
lea    0xbb5(%rip),%rsi
mov    $0x3d,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
mov    0x2b46(%rip),%rax
mov    (%rax),%eax
mov    0x2b25(%rip),%rcx
cmp    (%rcx),%eax
je     14d0 <main+0x2f0>
mov    0x2b2e(%rip),%rax
mov    (%rax),%ecx
lea    0xd1d(%rip),%rdi
lea    0xb70(%rip),%rsi
mov    $0x40,%edx
mov    $0x0,%al
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
jmp    14d5 <main+0x2f5>
mov    -0x40(%rbp),%rsi
mov    -0x48(%rbp),%rax
sub    $0x1,%rax
mov    %eax,%edx
lea    0xc6f(%rip),%rdi
call   1040 <readlink@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    1529 <main+0x349>
mov    0x2ad5(%rip),%rax
mov    (%rax),%ecx
lea    0xcf0(%rip),%rdi
lea    0xb17(%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     155e <main+0x37e>
mov    -0x40(%rbp),%rdx
mov    -0x50(%rbp),%rsi
lea    0xcdb(%rip),%rdi
mov    $0x0,%al
call   1080 <test_msg@plt>
lea    0xce4(%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    0x2dfb(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%r12
lea    0xf(%r15),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
call   1030 <test_init@plt>
xor    %eax,%eax
call   1100 <fork@plt>
test   %eax,%eax
js     135e <main+0x17e>
je     1346 <main+0x166>
mov    %eax,%ebx
lea    0xe93(%rip),%rsi
mov    %r12,%rdi
mov    %eax,%edx
call   10e0 <sprintf@plt>
mov    %r12,%rdi
call   1050 <chdir@plt>
mov    %rax,%r13
mov    0x2d7f(%rip),%rax
mov    (%rax),%esi
mov    %ebx,%edi
call   10b0 <kill@plt>
test   %r13,%r13
js     137f <main+0x19f>
mov    %ebx,%edi
xor    %esi,%esi
xor    %edx,%edx
call   10d0 <waitpid@plt>
mov    %r12,%rdi
mov    %r15d,%esi
call   1070 <getcwd@plt>
mov    0x2d58(%rip),%r13
mov    0x0(%r13),%r8d
test   %rax,%rax
jne    13a0 <main+0x1c0>
mov    0x2d2c(%rip),%rbx
cmp    (%rbx),%r8d
jne    13b8 <main+0x1d8>
lea    0xeb5(%rip),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
call   1040 <readlink@plt>
test   %eax,%eax
js     13cd <main+0x1ed>
mov    %eax,%eax
movb   $0x0,(%r12,%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    0x0(%r13),%r8d
test   %rax,%rax
jne    13e6 <main+0x206>
cmp    (%rbx),%r8d
jne    140d <main+0x22d>
add    $0xffffffff,%r15d
lea    0xe61(%rip),%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1040 <readlink@plt>
test   %eax,%eax
js     1425 <main+0x245>
mov    %eax,%eax
movb   $0x0,(%r14,%rax,1)
mov    %r12,%rdi
mov    %r14,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1336 <main+0x156>
lea    0xf09(%rip),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <test_msg@plt>
lea    0xf0c(%rip),%rdi
xor    %eax,%eax
call   1080 <test_msg@plt>
jmp    134d <main+0x16d>
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    0x2c73(%rip),%rax
mov    (%rax),%ecx
lea    0xc92(%rip),%rdi
lea    0xcb5(%rip),%rsi
mov    $0x18,%edx
jmp    143c <main+0x25c>
mov    0x2c52(%rip),%rax
mov    (%rax),%ecx
lea    0xd42(%rip),%rdi
lea    0xc94(%rip),%rsi
mov    $0x23,%edx
jmp    143c <main+0x25c>
lea    0xd55(%rip),%rdi
lea    0xc7c(%rip),%rsi
mov    $0x2b,%edx
mov    %r12,%rcx
jmp    13fc <main+0x21c>
lea    0xd6f(%rip),%rdi
lea    0xc64(%rip),%rsi
mov    $0x2e,%edx
jmp    1420 <main+0x240>
mov    0x0(%r13),%ecx
lea    0xd90(%rip),%rdi
lea    0xc4b(%rip),%rsi
mov    $0x34,%edx
jmp    143c <main+0x25c>
lea    0xdb0(%rip),%rdi
lea    0xc36(%rip),%rsi
mov    $0x3d,%edx
mov    %r14,%rcx
xor    %eax,%eax
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>
lea    0xdbc(%rip),%rdi
lea    0xc0f(%rip),%rsi
mov    $0x40,%edx
mov    %r8d,%ecx
jmp    143c <main+0x25c>
mov    0x0(%r13),%ecx
lea    0xdcc(%rip),%rdi
lea    0xbf3(%rip),%rsi
mov    $0x46,%edx
xor    %eax,%eax
call   1080 <test_msg@plt>
mov    $0x1,%edi
call   10f0 <exit@plt>

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

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