#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ F_OK;
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ S_IRWXU;
int /*<<< orphan*/ access_test(char *, int /*<<< orphan*/);
int /*<<< orphan*/ close_test(int);
int expect_gez(int /*<<< orphan*/, int);
int expect_ptr(int /*<<< orphan*/, char *);
int expect_zng(int, int /*<<< orphan*/);
int /*<<< orphan*/ fchdir_test(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *getcwd_test(int /*<<< orphan*/ *, int);
int open_test(char *, int, ...);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ testbreak();
int /*<<< orphan*/ unlink_test(char *);
int /*<<< orphan*/ xtmpnam(char *);
int BasicFchdir(void) {
  char tf[8192] = {0};
  int fd, fd2;
  int passed;
  int block = 0;
  char *cwdfile = "_.-'^`-._";
  char *cwd = NULL;
  char *cwd_chdir = NULL;
  int tmpfd;
  xtmpnam(tf);
  testbreak();
  passed = expect_ptr(0, cwd = getcwd_test(NULL, 8192));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  if (passed == -1) {
    printf("\tFail Phase 2: Aborting test because of catastrophic failure\n");
    fflush(NULL);
    return passed;
  };
  passed = expect_gez(
      0, fd = open_test(cwdfile, O_RDWR | O_TRUNC | O_CREAT, S_IRWXU));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_gez(0, tmpfd = open_test("/tmp", O_RDONLY));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, fchdir_test(tmpfd));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, close_test(tmpfd));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_ptr(0, cwd_chdir = getcwd_test(NULL, 8192));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  if (passed == -1) {
    free(cwd);
    {
      printf("\tFail Phase 2: Aborting test because of catastrophic failure\n");
      fflush(NULL);
      return passed;
    };
  }
  if (strcmp(cwd, cwd_chdir) == 0) {
    printf("\tFailed Phase 2: fchdir() did not change directories\n");
    fflush(NULL);
    block = -1;
  }
  if (cwd_chdir != NULL) {
    free(cwd_chdir);
  }
  passed = expect_zng(-1, access_test(cwdfile, F_OK));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_gez(
      0, fd2 = open_test(cwdfile, O_RDWR | O_TRUNC | O_CREAT, S_IRWXU));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, access_test(cwdfile, F_OK));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, close_test(fd2));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, unlink_test(cwdfile));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_gez(0, tmpfd = open_test(cwd, O_RDONLY));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, fchdir_test(tmpfd));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, close_test(tmpfd));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, access_test(cwdfile, F_OK));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, close_test(fd));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, unlink_test(cwdfile));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(-1, access_test(cwdfile, F_OK));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  free(cwd);
  testbreak();
  return block;
}


x86 assembly (clang, -O0):
<BasicFchdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2040,%rsp
lea    -0x2010(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1080 <memset@plt>
movl   $0x0,-0x2020(%rbp)
lea    0xdd1(%rip),%rax
mov    %rax,-0x2028(%rbp)
movq   $0x0,-0x2030(%rbp)
movq   $0x0,-0x2038(%rbp)
lea    -0x2010(%rbp),%rdi
call   1050 <xtmpnam@plt>
mov    $0x0,%al
call   10e0 <testbreak@plt>
xor    %eax,%eax
mov    %eax,%edi
mov    $0x2000,%esi
call   1110 <getcwd_test@plt>
mov    %rax,%rsi
mov    %rsi,-0x2030(%rbp)
xor    %edi,%edi
call   1040 <expect_ptr@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     12b0 <BasicFchdir+0xb0>
lea    0xd72(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
cmpl   $0xffffffff,-0x201c(%rbp)
jne    12e0 <BasicFchdir+0xe0>
lea    0xd7c(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
mov    -0x201c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    18ed <BasicFchdir+0x6ed>
mov    -0x2028(%rbp),%rdi
mov    0x2ce2(%rip),%rax
mov    (%rax),%esi
mov    0x2cf9(%rip),%rax
or     (%rax),%esi
mov    0x2cf8(%rip),%rax
or     (%rax),%esi
mov    0x2ccf(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1090 <open_test@plt>
mov    %eax,%esi
mov    %esi,-0x2014(%rbp)
xor    %edi,%edi
call   1120 <expect_gez@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     1353 <BasicFchdir+0x153>
lea    0xccf(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    0x2c6e(%rip),%rax
mov    (%rax),%esi
lea    0xd1b(%rip),%rdi
mov    $0x0,%al
call   1090 <open_test@plt>
mov    %eax,%esi
mov    %esi,-0x203c(%rbp)
xor    %edi,%edi
call   1120 <expect_gez@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     13ab <BasicFchdir+0x1ab>
lea    0xc77(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x203c(%rbp),%edi
call   10b0 <fchdir_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     13f1 <BasicFchdir+0x1f1>
lea    0xc31(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x203c(%rbp),%edi
call   1060 <close_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     1437 <BasicFchdir+0x237>
lea    0xbeb(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
xor    %eax,%eax
mov    %eax,%edi
mov    $0x2000,%esi
call   1110 <getcwd_test@plt>
mov    %rax,%rsi
mov    %rsi,-0x2038(%rbp)
xor    %edi,%edi
call   1040 <expect_ptr@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     1488 <BasicFchdir+0x288>
lea    0xb9a(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
cmpl   $0xffffffff,-0x201c(%rbp)
jne    14c4 <BasicFchdir+0x2c4>
mov    -0x2030(%rbp),%rdi
call   1030 <free@plt>
lea    0xb98(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
mov    -0x201c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    18ed <BasicFchdir+0x6ed>
mov    -0x2030(%rbp),%rdi
mov    -0x2038(%rbp),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1500 <BasicFchdir+0x300>
lea    0xb9b(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
cmpq   $0x0,-0x2038(%rbp)
je     151a <BasicFchdir+0x31a>
mov    -0x2038(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2028(%rbp),%rdi
mov    0x2a88(%rip),%rax
mov    (%rax),%esi
call   1100 <access_test@plt>
mov    %eax,%esi
mov    $0xffffffff,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     156d <BasicFchdir+0x36d>
lea    0xab5(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2028(%rbp),%rdi
mov    0x2a55(%rip),%rax
mov    (%rax),%esi
mov    0x2a6c(%rip),%rax
or     (%rax),%esi
mov    0x2a6b(%rip),%rax
or     (%rax),%esi
mov    0x2a42(%rip),%rax
mov    (%rax),%edx
mov    $0x0,%al
call   1090 <open_test@plt>
mov    %eax,%esi
mov    %esi,-0x2018(%rbp)
xor    %edi,%edi
call   1120 <expect_gez@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     15e0 <BasicFchdir+0x3e0>
lea    0xa42(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2028(%rbp),%rdi
mov    0x29c2(%rip),%rax
mov    (%rax),%esi
call   1100 <access_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     1630 <BasicFchdir+0x430>
lea    0x9f2(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2018(%rbp),%edi
call   1060 <close_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     1676 <BasicFchdir+0x476>
lea    0x9ac(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2028(%rbp),%rdi
call   10f0 <unlink_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     16bd <BasicFchdir+0x4bd>
lea    0x965(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2030(%rbp),%rdi
mov    0x28fd(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1090 <open_test@plt>
mov    %eax,%esi
mov    %esi,-0x203c(%rbp)
xor    %edi,%edi
call   1120 <expect_gez@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     1715 <BasicFchdir+0x515>
lea    0x90d(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x203c(%rbp),%edi
call   10b0 <fchdir_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     175b <BasicFchdir+0x55b>
lea    0x8c7(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x203c(%rbp),%edi
call   1060 <close_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     17a1 <BasicFchdir+0x5a1>
lea    0x881(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2028(%rbp),%rdi
mov    0x2801(%rip),%rax
mov    (%rax),%esi
call   1100 <access_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     17f1 <BasicFchdir+0x5f1>
lea    0x831(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2014(%rbp),%edi
call   1060 <close_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     1837 <BasicFchdir+0x637>
lea    0x7eb(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2028(%rbp),%rdi
call   10f0 <unlink_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     187e <BasicFchdir+0x67e>
lea    0x7a4(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2028(%rbp),%rdi
mov    0x2724(%rip),%rax
mov    (%rax),%esi
call   1100 <access_test@plt>
mov    %eax,%esi
mov    $0xffffffff,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     18d1 <BasicFchdir+0x6d1>
lea    0x751(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2030(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   10e0 <testbreak@plt>
mov    -0x2020(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BasicFchdir>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2008,%rsp
mov    %rsp,%rbx
xor    %r12d,%r12d
mov    $0x2000,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1080 <memset@plt>
mov    %rbx,%rdi
call   1060 <xtmpnam@plt>
xor    %eax,%eax
call   10e0 <testbreak@plt>
xor    %edi,%edi
mov    $0x2000,%esi
call   1110 <getcwd_test@plt>
mov    %rax,%r15
xor    %edi,%edi
mov    %rax,%rsi
call   1050 <expect_ptr@plt>
test   %eax,%eax
je     1276 <BasicFchdir+0x76>
mov    %eax,%ebx
lea    0xe26(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
cmp    $0xffffffff,%ebx
je     1698 <BasicFchdir+0x498>
mov    0x2d53(%rip),%rax
mov    0x2d6c(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d69(%rip),%rax
or     (%rax),%esi
mov    0x2d40(%rip),%r13
mov    0x0(%r13),%edx
lea    0xd5d(%rip),%rdi
xor    %eax,%eax
call   1090 <open_test@plt>
mov    %eax,%r14d
xor    %edi,%edi
mov    %eax,%esi
call   1120 <expect_gez@plt>
test   %eax,%eax
je     12d3 <BasicFchdir+0xd3>
lea    0xdc0(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    0x2cee(%rip),%rax
mov    (%rax),%esi
lea    0xd27(%rip),%rdi
xor    %eax,%eax
call   1090 <open_test@plt>
mov    %eax,%ebx
xor    %edi,%edi
mov    %eax,%esi
call   1120 <expect_gez@plt>
test   %eax,%eax
je     1312 <BasicFchdir+0x112>
lea    0xd81(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %ebx,%edi
call   10b0 <fchdir_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     133f <BasicFchdir+0x13f>
lea    0xd54(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %ebx,%edi
call   1070 <close_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     136c <BasicFchdir+0x16c>
lea    0xd27(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
xor    %edi,%edi
mov    $0x2000,%esi
call   1110 <getcwd_test@plt>
mov    %rax,%rbx
xor    %edi,%edi
mov    %rax,%rsi
call   1050 <expect_ptr@plt>
test   %eax,%eax
je     13ad <BasicFchdir+0x1ad>
mov    %eax,%ebp
lea    0xcef(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
cmp    $0xffffffff,%ebp
je     1690 <BasicFchdir+0x490>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1669 <BasicFchdir+0x469>
test   %rbx,%rbx
je     13ce <BasicFchdir+0x1ce>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    0x2bdb(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0xc21(%rip),%rdi
call   1100 <access_test@plt>
mov    $0xffffffff,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     140d <BasicFchdir+0x20d>
lea    0xc86(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    0x2bdc(%rip),%rax
mov    (%rax),%esi
mov    0x2bb3(%rip),%rax
or     (%rax),%esi
mov    0x2bd2(%rip),%rax
or     (%rax),%esi
mov    0x0(%r13),%edx
lea    0xbcd(%rip),%rdi
xor    %eax,%eax
call   1090 <open_test@plt>
mov    %eax,%ebx
xor    %edi,%edi
mov    %eax,%esi
call   1120 <expect_gez@plt>
test   %eax,%eax
je     1462 <BasicFchdir+0x262>
lea    0xc31(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    0x0(%rbp),%esi
lea    0xb94(%rip),%rdi
call   1100 <access_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     1497 <BasicFchdir+0x297>
lea    0xbfc(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %ebx,%edi
call   1070 <close_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     14c4 <BasicFchdir+0x2c4>
lea    0xbcf(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
lea    0xb35(%rip),%rdi
call   10f0 <unlink_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     14f6 <BasicFchdir+0x2f6>
lea    0xb9d(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    0x2acb(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1090 <open_test@plt>
mov    %eax,%ebx
xor    %edi,%edi
mov    %eax,%esi
call   1120 <expect_gez@plt>
test   %eax,%eax
je     1531 <BasicFchdir+0x331>
lea    0xb62(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %ebx,%edi
call   10b0 <fchdir_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     155e <BasicFchdir+0x35e>
lea    0xb35(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %ebx,%edi
call   1070 <close_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     158b <BasicFchdir+0x38b>
lea    0xb08(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    0x0(%rbp),%esi
lea    0xa6b(%rip),%rdi
call   1100 <access_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     15c0 <BasicFchdir+0x3c0>
lea    0xad3(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %r14d,%edi
call   1070 <close_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     15ee <BasicFchdir+0x3ee>
lea    0xaa5(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
lea    0xa0b(%rip),%rdi
call   10f0 <unlink_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     1620 <BasicFchdir+0x420>
lea    0xa73(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    0x0(%rbp),%esi
lea    0x9d6(%rip),%rdi
call   1100 <access_test@plt>
mov    $0xffffffff,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     1658 <BasicFchdir+0x458>
lea    0xa3b(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   10e0 <testbreak@plt>
jmp    16b1 <BasicFchdir+0x4b1>
lea    0x99f(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
test   %rbx,%rbx
jne    13c6 <BasicFchdir+0x1c6>
jmp    13ce <BasicFchdir+0x1ce>
mov    %r15,%rdi
call   1030 <free@plt>
lea    0x9a5(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10d0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %r12d,%eax
add    $0x2008,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"_.-'^`-._\00"
@.str.1 = [54 x i8] c"\09Failed Phase 2: This call did something unexpected.\0A\00"
@.str.2 = [62 x i8] c"\09Fail Phase 2: Aborting test because of catastrophic failure\0A\00"
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@S_IRWXU = global i32 0
@.str.3 = [5 x i8] c"/tmp\00"
@O_RDONLY = global i32 0
@.str.4 = [54 x i8] c"\09Failed Phase 2: fchdir() did not change directories\0A\00"
@F_OK = global i32 0
define i32 @BasicFchdir() {
%1 = alloca i32
%2 = alloca [8192 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = bitcast [8192 x i8]* %2 to i8*
store i32 0, i32* %6
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* null, i8** %8
store i8* null, i8** %9
%12 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%13 = call i32 @xtmpnam(i8* %12)
%14 = call i32 (...) @testbreak()
%15 = call i8* @getcwd_test(i32* null, i32 8192)
store i8* %15, i8** %8
%16 = call i32 @expect_ptr(i32 0, i8* %15)
store i32 %16, i32* %5
%17 = load i32, i32* %5
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %22
22: ; preds = %19, %0
%23 = load i32, i32* %5
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @fflush(i32* null)
%28 = load i32, i32* %5
store i32 %28, i32* %1
br label %226
29: ; preds = %22
%30 = load i8*, i8** %7
%31 = load i32, i32* @O_RDWR
%32 = load i32, i32* @O_TRUNC
%33 = or i32 %31, %32
%34 = load i32, i32* @O_CREAT
%35 = or i32 %33, %34
%36 = load i32, i32* @S_IRWXU
%37 = call i32 (i8*, i32, ...) @open_test(i8* %30, i32 %35, i32 %36)
store i32 %37, i32* %3
%38 = call i32 @expect_gez(i32 0, i32 %37)
store i32 %38, i32* %5
%39 = load i32, i32* %5
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %29
%42 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%43 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %44
44: ; preds = %41, %29
%45 = load i32, i32* @O_RDONLY
%46 = call i32 (i8*, i32, ...) @open_test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %45)
store i32 %46, i32* %10
%47 = call i32 @expect_gez(i32 0, i32 %46)
store i32 %47, i32* %5
%48 = load i32, i32* %5
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %53
50: ; preds = %44
%51 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%52 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %53
53: ; preds = %50, %44
%54 = load i32, i32* %10
%55 = call i32 @fchdir_test(i32 %54)
%56 = call i32 @expect_zng(i32 0, i32 %55)
store i32 %56, i32* %5
%57 = load i32, i32* %5
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %53
%60 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%61 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %62
62: ; preds = %59, %53
%63 = load i32, i32* %10
%64 = call i32 @close_test(i32 %63)
%65 = call i32 @expect_zng(i32 0, i32 %64)
store i32 %65, i32* %5
%66 = load i32, i32* %5
%67 = icmp ne i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %62
%69 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%70 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %71
71: ; preds = %68, %62
%72 = call i8* @getcwd_test(i32* null, i32 8192)
store i8* %72, i8** %9
%73 = call i32 @expect_ptr(i32 0, i8* %72)
store i32 %73, i32* %5
%74 = load i32, i32* %5
%75 = icmp ne i32 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %71
%77 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%78 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %79
79: ; preds = %76, %71
%80 = load i32, i32* %5
%81 = icmp eq i32 %80, -1
br i1 %81, label %82, label %88
82: ; preds = %79
%83 = load i8*, i8** %8
%84 = call i32 @free(i8* %83)
%85 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%86 = call i32 @fflush(i32* null)
%87 = load i32, i32* %5
store i32 %87, i32* %1
br label %226
88: ; preds = %79
%89 = load i8*, i8** %8
%90 = load i8*, i8** %9
%91 = call i64 @strcmp(i8* %89, i8* %90)
%92 = icmp eq i64 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %88
%94 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.4, i64 0, i64 0))
%95 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %96
96: ; preds = %93, %88
%97 = load i8*, i8** %9
%98 = icmp ne i8* %97, null
br i1 %98, label %99, label %102
99: ; preds = %96
%100 = load i8*, i8** %9
%101 = call i32 @free(i8* %100)
br label %102
102: ; preds = %99, %96
%103 = load i8*, i8** %7
%104 = load i32, i32* @F_OK
%105 = call i32 @access_test(i8* %103, i32 %104)
%106 = call i32 @expect_zng(i32 -1, i32 %105)
store i32 %106, i32* %5
%107 = load i32, i32* %5
%108 = icmp ne i32 %107, 0
br i1 %108, label %109, label %112
109: ; preds = %102
%110 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%111 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %112
112: ; preds = %109, %102
%113 = load i8*, i8** %7
%114 = load i32, i32* @O_RDWR
%115 = load i32, i32* @O_TRUNC
%116 = or i32 %114, %115
%117 = load i32, i32* @O_CREAT
%118 = or i32 %116, %117
%119 = load i32, i32* @S_IRWXU
%120 = call i32 (i8*, i32, ...) @open_test(i8* %113, i32 %118, i32 %119)
store i32 %120, i32* %4
%121 = call i32 @expect_gez(i32 0, i32 %120)
store i32 %121, i32* %5
%122 = load i32, i32* %5
%123 = icmp ne i32 %122, 0
br i1 %123, label %124, label %127
124: ; preds = %112
%125 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%126 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %127
127: ; preds = %124, %112
%128 = load i8*, i8** %7
%129 = load i32, i32* @F_OK
%130 = call i32 @access_test(i8* %128, i32 %129)
%131 = call i32 @expect_zng(i32 0, i32 %130)
store i32 %131, i32* %5
%132 = load i32, i32* %5
%133 = icmp ne i32 %132, 0
br i1 %133, label %134, label %137
134: ; preds = %127
%135 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%136 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %137
137: ; preds = %134, %127
%138 = load i32, i32* %4
%139 = call i32 @close_test(i32 %138)
%140 = call i32 @expect_zng(i32 0, i32 %139)
store i32 %140, i32* %5
%141 = load i32, i32* %5
%142 = icmp ne i32 %141, 0
br i1 %142, label %143, label %146
143: ; preds = %137
%144 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%145 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %146
146: ; preds = %143, %137
%147 = load i8*, i8** %7
%148 = call i32 @unlink_test(i8* %147)
%149 = call i32 @expect_zng(i32 0, i32 %148)
store i32 %149, i32* %5
%150 = load i32, i32* %5
%151 = icmp ne i32 %150, 0
br i1 %151, label %152, label %155
152: ; preds = %146
%153 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%154 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %155
155: ; preds = %152, %146
%156 = load i8*, i8** %8
%157 = load i32, i32* @O_RDONLY
%158 = call i32 (i8*, i32, ...) @open_test(i8* %156, i32 %157)
store i32 %158, i32* %10
%159 = call i32 @expect_gez(i32 0, i32 %158)
store i32 %159, i32* %5
%160 = load i32, i32* %5
%161 = icmp ne i32 %160, 0
br i1 %161, label %162, label %165
162: ; preds = %155
%163 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%164 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %165
165: ; preds = %162, %155
%166 = load i32, i32* %10
%167 = call i32 @fchdir_test(i32 %166)
%168 = call i32 @expect_zng(i32 0, i32 %167)
store i32 %168, i32* %5
%169 = load i32, i32* %5
%170 = icmp ne i32 %169, 0
br i1 %170, label %171, label %174
171: ; preds = %165
%172 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%173 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %174
174: ; preds = %171, %165
%175 = load i32, i32* %10
%176 = call i32 @close_test(i32 %175)
%177 = call i32 @expect_zng(i32 0, i32 %176)
store i32 %177, i32* %5
%178 = load i32, i32* %5
%179 = icmp ne i32 %178, 0
br i1 %179, label %180, label %183
180: ; preds = %174
%181 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%182 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %183
183: ; preds = %180, %174
%184 = load i8*, i8** %7
%185 = load i32, i32* @F_OK
%186 = call i32 @access_test(i8* %184, i32 %185)
%187 = call i32 @expect_zng(i32 0, i32 %186)
store i32 %187, i32* %5
%188 = load i32, i32* %5
%189 = icmp ne i32 %188, 0
br i1 %189, label %190, label %193
190: ; preds = %183
%191 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%192 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %193
193: ; preds = %190, %183
%194 = load i32, i32* %3
%195 = call i32 @close_test(i32 %194)
%196 = call i32 @expect_zng(i32 0, i32 %195)
store i32 %196, i32* %5
%197 = load i32, i32* %5
%198 = icmp ne i32 %197, 0
br i1 %198, label %199, label %202
199: ; preds = %193
%200 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%201 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %202
202: ; preds = %199, %193
%203 = load i8*, i8** %7
%204 = call i32 @unlink_test(i8* %203)
%205 = call i32 @expect_zng(i32 0, i32 %204)
store i32 %205, i32* %5
%206 = load i32, i32* %5
%207 = icmp ne i32 %206, 0
br i1 %207, label %208, label %211
208: ; preds = %202
%209 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%210 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %211
211: ; preds = %208, %202
%212 = load i8*, i8** %7
%213 = load i32, i32* @F_OK
%214 = call i32 @access_test(i8* %212, i32 %213)
%215 = call i32 @expect_zng(i32 -1, i32 %214)
store i32 %215, i32* %5
%216 = load i32, i32* %5
%217 = icmp ne i32 %216, 0
br i1 %217, label %218, label %221
218: ; preds = %211
%219 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%220 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %221
221: ; preds = %218, %211
%222 = load i8*, i8** %8
%223 = call i32 @free(i8* %222)
%224 = call i32 (...) @testbreak()
%225 = load i32, i32* %6
store i32 %225, i32* %1
br label %226
226: ; preds = %221, %82, %25
%227 = load i32, i32* %1
ret i32 %227
}

LLVM IR (-O2):
@.str = [10 x i8] c"_.-'^`-._\00"
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@S_IRWXU = global i32 0
@.str.3 = [5 x i8] c"/tmp\00"
@O_RDONLY = global i32 0
@F_OK = global i32 0
@str.16 = [53 x i8] c"\09Failed Phase 2: fchdir() did not change directories\00"
@str.23 = [61 x i8] c"\09Fail Phase 2: Aborting test because of catastrophic failure\00"
@str.24 = [53 x i8] c"\09Failed Phase 2: This call did something unexpected.\00"
define i32 @BasicFchdir() {
%1 = alloca [8192 x i8]
%2 = getelementptr inbounds [8192 x i8], [8192 x i8]* %1, i64 0, i64 0
%3 = call i32 @xtmpnam(i8* %2)
%4 = call i32 (...) @testbreak()
%5 = call i8* @getcwd_test(i32* null, i32 8192)
%6 = call i32 @expect_ptr(i32 0, i8* %5)
%7 = icmp eq i32 %6, 0
br i1 %7, label %15, label %8
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%10 = call i32 @fflush(i32* null)
%11 = icmp eq i32 %6, -1
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.23, i64 0, i64 0))
%14 = call i32 @fflush(i32* null)
br label %189
15: ; preds = %0, %8
%16 = phi i32 [ -1, %8 ], [ 0, %0 ]
%17 = load i32, i32* @O_RDWR
%18 = load i32, i32* @O_TRUNC
%19 = or i32 %18, %17
%20 = load i32, i32* @O_CREAT
%21 = or i32 %19, %20
%22 = load i32, i32* @S_IRWXU
%23 = call i32 (i8*, i32, ...) @open_test(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22)
%24 = call i32 @expect_gez(i32 0, i32 %23)
%25 = icmp eq i32 %24, 0
br i1 %25, label %29, label %26
26: ; preds = %15
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%28 = call i32 @fflush(i32* null)
br label %29
29: ; preds = %26, %15
%30 = phi i32 [ -1, %26 ], [ %16, %15 ]
%31 = load i32, i32* @O_RDONLY
%32 = call i32 (i8*, i32, ...) @open_test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %31)
%33 = call i32 @expect_gez(i32 0, i32 %32)
%34 = icmp eq i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %29
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%37 = call i32 @fflush(i32* null)
br label %38
38: ; preds = %35, %29
%39 = phi i32 [ -1, %35 ], [ %30, %29 ]
%40 = call i32 @fchdir_test(i32 %32)
%41 = call i32 @expect_zng(i32 0, i32 %40)
%42 = icmp eq i32 %41, 0
br i1 %42, label %46, label %43
43: ; preds = %38
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%45 = call i32 @fflush(i32* null)
br label %46
46: ; preds = %43, %38
%47 = phi i32 [ -1, %43 ], [ %39, %38 ]
%48 = call i32 @close_test(i32 %32)
%49 = call i32 @expect_zng(i32 0, i32 %48)
%50 = icmp eq i32 %49, 0
br i1 %50, label %54, label %51
51: ; preds = %46
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%53 = call i32 @fflush(i32* null)
br label %54
54: ; preds = %51, %46
%55 = phi i32 [ -1, %51 ], [ %47, %46 ]
%56 = call i8* @getcwd_test(i32* null, i32 8192)
%57 = call i32 @expect_ptr(i32 0, i8* %56)
%58 = icmp eq i32 %57, 0
br i1 %58, label %67, label %59
59: ; preds = %54
%60 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%61 = call i32 @fflush(i32* null)
%62 = icmp eq i32 %57, -1
br i1 %62, label %63, label %67
63: ; preds = %59
%64 = call i32 @free(i8* %5)
%65 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.23, i64 0, i64 0))
%66 = call i32 @fflush(i32* null)
br label %189
67: ; preds = %54, %59
%68 = phi i32 [ -1, %59 ], [ %55, %54 ]
%69 = call i64 @strcmp(i8* %5, i8* %56)
%70 = icmp eq i64 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %67
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%73 = call i32 @fflush(i32* null)
br label %74
74: ; preds = %71, %67
%75 = phi i32 [ -1, %71 ], [ %68, %67 ]
%76 = icmp eq i8* %56, null
br i1 %76, label %79, label %77
77: ; preds = %74
%78 = call i32 @free(i8* %56)
br label %79
79: ; preds = %77, %74
%80 = load i32, i32* @F_OK
%81 = call i32 @access_test(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %80)
%82 = call i32 @expect_zng(i32 -1, i32 %81)
%83 = icmp eq i32 %82, 0
br i1 %83, label %87, label %84
84: ; preds = %79
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%86 = call i32 @fflush(i32* null)
br label %87
87: ; preds = %84, %79
%88 = phi i32 [ -1, %84 ], [ %75, %79 ]
%89 = load i32, i32* @O_RDWR
%90 = load i32, i32* @O_TRUNC
%91 = or i32 %90, %89
%92 = load i32, i32* @O_CREAT
%93 = or i32 %91, %92
%94 = load i32, i32* @S_IRWXU
%95 = call i32 (i8*, i32, ...) @open_test(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %93, i32 %94)
%96 = call i32 @expect_gez(i32 0, i32 %95)
%97 = icmp eq i32 %96, 0
br i1 %97, label %101, label %98
98: ; preds = %87
%99 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%100 = call i32 @fflush(i32* null)
br label %101
101: ; preds = %98, %87
%102 = phi i32 [ -1, %98 ], [ %88, %87 ]
%103 = load i32, i32* @F_OK
%104 = call i32 @access_test(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %103)
%105 = call i32 @expect_zng(i32 0, i32 %104)
%106 = icmp eq i32 %105, 0
br i1 %106, label %110, label %107
107: ; preds = %101
%108 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%109 = call i32 @fflush(i32* null)
br label %110
110: ; preds = %107, %101
%111 = phi i32 [ -1, %107 ], [ %102, %101 ]
%112 = call i32 @close_test(i32 %95)
%113 = call i32 @expect_zng(i32 0, i32 %112)
%114 = icmp eq i32 %113, 0
br i1 %114, label %118, label %115
115: ; preds = %110
%116 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%117 = call i32 @fflush(i32* null)
br label %118
118: ; preds = %115, %110
%119 = phi i32 [ -1, %115 ], [ %111, %110 ]
%120 = call i32 @unlink_test(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%121 = call i32 @expect_zng(i32 0, i32 %120)
%122 = icmp eq i32 %121, 0
br i1 %122, label %126, label %123
123: ; preds = %118
%124 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%125 = call i32 @fflush(i32* null)
br label %126
126: ; preds = %123, %118
%127 = phi i32 [ -1, %123 ], [ %119, %118 ]
%128 = load i32, i32* @O_RDONLY
%129 = call i32 (i8*, i32, ...) @open_test(i8* %5, i32 %128)
%130 = call i32 @expect_gez(i32 0, i32 %129)
%131 = icmp eq i32 %130, 0
br i1 %131, label %135, label %132
132: ; preds = %126
%133 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%134 = call i32 @fflush(i32* null)
br label %135
135: ; preds = %132, %126
%136 = phi i32 [ -1, %132 ], [ %127, %126 ]
%137 = call i32 @fchdir_test(i32 %129)
%138 = call i32 @expect_zng(i32 0, i32 %137)
%139 = icmp eq i32 %138, 0
br i1 %139, label %143, label %140
140: ; preds = %135
%141 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%142 = call i32 @fflush(i32* null)
br label %143
143: ; preds = %140, %135
%144 = phi i32 [ -1, %140 ], [ %136, %135 ]
%145 = call i32 @close_test(i32 %129)
%146 = call i32 @expect_zng(i32 0, i32 %145)
%147 = icmp eq i32 %146, 0
br i1 %147, label %151, label %148
148: ; preds = %143
%149 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%150 = call i32 @fflush(i32* null)
br label %151
151: ; preds = %148, %143
%152 = phi i32 [ -1, %148 ], [ %144, %143 ]
%153 = load i32, i32* @F_OK
%154 = call i32 @access_test(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %153)
%155 = call i32 @expect_zng(i32 0, i32 %154)
%156 = icmp eq i32 %155, 0
br i1 %156, label %160, label %157
157: ; preds = %151
%158 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%159 = call i32 @fflush(i32* null)
br label %160
160: ; preds = %157, %151
%161 = phi i32 [ -1, %157 ], [ %152, %151 ]
%162 = call i32 @close_test(i32 %23)
%163 = call i32 @expect_zng(i32 0, i32 %162)
%164 = icmp eq i32 %163, 0
br i1 %164, label %168, label %165
165: ; preds = %160
%166 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%167 = call i32 @fflush(i32* null)
br label %168
168: ; preds = %165, %160
%169 = phi i32 [ -1, %165 ], [ %161, %160 ]
%170 = call i32 @unlink_test(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%171 = call i32 @expect_zng(i32 0, i32 %170)
%172 = icmp eq i32 %171, 0
br i1 %172, label %176, label %173
173: ; preds = %168
%174 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%175 = call i32 @fflush(i32* null)
br label %176
176: ; preds = %173, %168
%177 = phi i32 [ -1, %173 ], [ %169, %168 ]
%178 = load i32, i32* @F_OK
%179 = call i32 @access_test(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %178)
%180 = call i32 @expect_zng(i32 -1, i32 %179)
%181 = icmp eq i32 %180, 0
br i1 %181, label %185, label %182
182: ; preds = %176
%183 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.24, i64 0, i64 0))
%184 = call i32 @fflush(i32* null)
br label %185
185: ; preds = %182, %176
%186 = phi i32 [ -1, %182 ], [ %177, %176 ]
%187 = call i32 @free(i8* %5)
%188 = call i32 (...) @testbreak()
br label %189
189: ; preds = %185, %63, %12
%190 = phi i32 [ -1, %12 ], [ -1, %63 ], [ %186, %185 ]
ret i32 %190
}