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

/* Forward declarations */

/* Type definitions */
struct stat {
  int dummy;
};

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

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
}