#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 O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ S_IRWXU;
int /*<<< orphan*/ access_test(char *, int /*<<< orphan*/);
int /*<<< orphan*/ chdir_test(char *);
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*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *getcwd_test(int /*<<< orphan*/ *, int);
int open_test(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ testbreak();
int /*<<< orphan*/ unlink_test(char *);
int /*<<< orphan*/ xtmpnam(char *);
int BasicChdir(void) {
  char tf[8192] = {0};
  int fd, fd2;
  int passed;
  int block = 0;
  char *cwdfile = "_.-'^`-._";
  char *cwd = NULL;
  char *cwd_chdir = NULL;
  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;
  };
  if (passed == -1) {
    free(cwd);
    {
      printf("\tFail Phase 2: Aborting test because of catastrophic failure\n");
      fflush(NULL);
      return passed;
    };
  }
  passed = expect_zng(0, chdir_test("/tmp"));
  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: chdir() 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;
  };
  if (passed == -1) {
    free(cwd);
    {
      printf("\tFail Phase 2: Aborting test because of catastrophic failure\n");
      fflush(NULL);
      return passed;
    };
  }
  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_zng(0, chdir_test(cwd));
  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;
  };
  if (cwd)
    free(cwd);
  testbreak();
  return block;
}


x86 assembly (clang, -O0):
<BasicChdir>:
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   10d0 <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 <BasicChdir+0xb0>
lea    0xd72(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
cmpl   $0xffffffff,-0x201c(%rbp)
jne    12e0 <BasicChdir+0xe0>
lea    0xd7c(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
mov    -0x201c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1835 <BasicChdir+0x635>
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
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     1351 <BasicChdir+0x151>
lea    0xcd1(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
cmpl   $0xffffffff,-0x201c(%rbp)
jne    138d <BasicChdir+0x18d>
mov    -0x2030(%rbp),%rdi
call   1030 <free@plt>
lea    0xccf(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
mov    -0x201c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1835 <BasicChdir+0x635>
lea    0xcea(%rip),%rdi
call   10e0 <chdir_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10b0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     13d4 <BasicChdir+0x1d4>
lea    0xc4e(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <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     1425 <BasicChdir+0x225>
lea    0xbfd(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
cmpl   $0xffffffff,-0x201c(%rbp)
jne    1461 <BasicChdir+0x261>
mov    -0x2030(%rbp),%rdi
call   1030 <free@plt>
lea    0xbfb(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
mov    -0x201c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1835 <BasicChdir+0x635>
mov    -0x2030(%rbp),%rdi
mov    -0x2038(%rbp),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    149d <BasicChdir+0x29d>
lea    0xbfe(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
cmpq   $0x0,-0x2038(%rbp)
je     14b7 <BasicChdir+0x2b7>
mov    -0x2038(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2028(%rbp),%rdi
mov    0x2af3(%rip),%rax
mov    (%rax),%esi
call   1100 <access_test@plt>
mov    %eax,%esi
mov    $0xffffffff,%edi
call   10b0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     150a <BasicChdir+0x30a>
lea    0xb18(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2028(%rbp),%rdi
mov    0x2ab8(%rip),%rax
mov    (%rax),%esi
mov    0x2acf(%rip),%rax
or     (%rax),%esi
mov    0x2ace(%rip),%rax
or     (%rax),%esi
mov    0x2aa5(%rip),%rax
mov    (%rax),%edx
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     157b <BasicChdir+0x37b>
lea    0xaa7(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
cmpl   $0xffffffff,-0x201c(%rbp)
jne    15b7 <BasicChdir+0x3b7>
mov    -0x2030(%rbp),%rdi
call   1030 <free@plt>
lea    0xaa5(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
mov    -0x201c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1835 <BasicChdir+0x635>
mov    -0x2028(%rbp),%rdi
mov    0x29f3(%rip),%rax
mov    (%rax),%esi
call   1100 <access_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10b0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     1607 <BasicChdir+0x407>
lea    0xa1b(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <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   10b0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     164d <BasicChdir+0x44d>
lea    0x9d5(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <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   10b0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     1694 <BasicChdir+0x494>
lea    0x98e(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2030(%rbp),%rdi
call   10e0 <chdir_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10b0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     16db <BasicChdir+0x4db>
lea    0x947(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2028(%rbp),%rdi
mov    0x28cf(%rip),%rax
mov    (%rax),%esi
call   1100 <access_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10b0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     172b <BasicChdir+0x52b>
lea    0x8f7(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <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   10b0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     1771 <BasicChdir+0x571>
lea    0x8b1(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <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   10b0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     17b8 <BasicChdir+0x5b8>
lea    0x86a(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
mov    -0x2028(%rbp),%rdi
mov    0x27f2(%rip),%rax
mov    (%rax),%esi
call   1100 <access_test@plt>
mov    %eax,%esi
mov    $0xffffffff,%edi
call   10b0 <expect_zng@plt>
mov    %eax,-0x201c(%rbp)
cmpl   $0x0,-0x201c(%rbp)
je     180b <BasicChdir+0x60b>
lea    0x817(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10c0 <fflush@plt>
movl   $0xffffffff,-0x2020(%rbp)
ff ff ff
cmpq   $0x0,-0x2030(%rbp)
je     1825 <BasicChdir+0x625>
mov    -0x2030(%rbp),%rdi
call   1030 <free@plt>
mov    $0x0,%al
call   10d0 <testbreak@plt>
mov    -0x2020(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BasicChdir>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2018,%rsp
lea    0x10(%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   10d0 <testbreak@plt>
xor    %edi,%edi
mov    $0x2000,%esi
call   1110 <getcwd_test@plt>
mov    %rax,%r14
xor    %edi,%edi
mov    %rax,%rsi
call   1050 <expect_ptr@plt>
test   %eax,%eax
je     1278 <BasicChdir+0x78>
mov    %eax,%ebp
lea    0xe23(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
cmp    $0xffffffff,%ebp
je     15c3 <BasicChdir+0x3c3>
mov    0x2d51(%rip),%rax
mov    0x2d6a(%rip),%r13
mov    0x0(%r13),%esi
or     (%rax),%esi
mov    0x2d65(%rip),%rax
or     (%rax),%esi
mov    0x2d3c(%rip),%r15
mov    (%r15),%edx
lea    0xd5a(%rip),%rdi
call   1090 <open_test@plt>
mov    %eax,%ebx
xor    %edi,%edi
mov    %eax,%esi
call   1120 <expect_gez@plt>
test   %eax,%eax
je     12de <BasicChdir+0xde>
mov    %eax,%ebp
lea    0xdbd(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
cmp    $0xffffffff,%ebp
je     15bb <BasicChdir+0x3bb>
mov    %ebx,0xc(%rsp)
lea    0xd21(%rip),%rdi
call   10e0 <chdir_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10b0 <expect_zng@plt>
test   %eax,%eax
je     1314 <BasicChdir+0x114>
lea    0xd7e(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
xor    %edi,%edi
mov    $0x2000,%esi
call   1110 <getcwd_test@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %rax,%rsi
call   1050 <expect_ptr@plt>
test   %eax,%eax
je     1355 <BasicChdir+0x155>
mov    %eax,%ebx
lea    0xd46(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
cmp    $0xffffffff,%ebx
je     15bb <BasicChdir+0x3bb>
mov    %r14,%rdi
mov    %rbp,%rsi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     15f1 <BasicChdir+0x3f1>
test   %rbp,%rbp
je     1376 <BasicChdir+0x176>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    0x2c3b(%rip),%rax
mov    (%rax),%esi
lea    0xc7a(%rip),%rdi
call   1100 <access_test@plt>
mov    $0xffffffff,%edi
mov    %eax,%esi
call   10b0 <expect_zng@plt>
test   %eax,%eax
je     13b4 <BasicChdir+0x1b4>
lea    0xcde(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    0x0(%r13),%esi
mov    0x2c11(%rip),%rax
or     (%rax),%esi
mov    0x2c30(%rip),%rax
or     (%rax),%esi
mov    (%r15),%edx
lea    0xc2c(%rip),%rdi
call   1090 <open_test@plt>
mov    %eax,%ebp
xor    %edi,%edi
mov    %eax,%esi
call   1120 <expect_gez@plt>
test   %eax,%eax
je     140c <BasicChdir+0x20c>
mov    %eax,%ebx
lea    0xc8f(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
cmp    $0xffffffff,%ebx
je     15bb <BasicChdir+0x3bb>
mov    0x2ba5(%rip),%r15
mov    (%r15),%esi
lea    0xbe3(%rip),%rdi
call   1100 <access_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10b0 <expect_zng@plt>
test   %eax,%eax
je     1448 <BasicChdir+0x248>
lea    0xc4a(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %ebp,%edi
call   1070 <close_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10b0 <expect_zng@plt>
test   %eax,%eax
mov    0xc(%rsp),%ebx
je     1479 <BasicChdir+0x279>
lea    0xc19(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
lea    0xb80(%rip),%rdi
call   10f0 <unlink_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10b0 <expect_zng@plt>
test   %eax,%eax
je     14ab <BasicChdir+0x2ab>
lea    0xbe7(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %r14,%rdi
call   10e0 <chdir_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10b0 <expect_zng@plt>
test   %eax,%eax
je     14d9 <BasicChdir+0x2d9>
lea    0xbb9(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    (%r15),%esi
lea    0xb1d(%rip),%rdi
call   1100 <access_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10b0 <expect_zng@plt>
test   %eax,%eax
je     150e <BasicChdir+0x30e>
lea    0xb84(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %ebx,%edi
call   1070 <close_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10b0 <expect_zng@plt>
test   %eax,%eax
je     153b <BasicChdir+0x33b>
lea    0xb57(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
lea    0xabe(%rip),%rdi
call   10f0 <unlink_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10b0 <expect_zng@plt>
test   %eax,%eax
je     156d <BasicChdir+0x36d>
lea    0xb25(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    (%r15),%esi
lea    0xa89(%rip),%rdi
call   1100 <access_test@plt>
mov    $0xffffffff,%edi
mov    %eax,%esi
call   10b0 <expect_zng@plt>
test   %eax,%eax
je     15a5 <BasicChdir+0x3a5>
lea    0xaed(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
test   %r14,%r14
je     15b2 <BasicChdir+0x3b2>
mov    %r14,%rdi
call   1030 <free@plt>
xor    %eax,%eax
call   10d0 <testbreak@plt>
jmp    15dc <BasicChdir+0x3dc>
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xa79(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
mov    %r12d,%eax
add    $0x2018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xa17(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   10c0 <fflush@plt>
mov    $0xffffffff,%r12d
test   %rbp,%rbp
jne    136e <BasicChdir+0x16e>
jmp    1376 <BasicChdir+0x176>

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"
@.str.4 = [53 x i8] c"\09Failed Phase 2: chdir() did not change directories\0A\00"
@F_OK = global i32 0
define i32 @BasicChdir() {
%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 %struct.stat
%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 %210
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 @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* %5
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %53
47: ; preds = %44
%48 = load i8*, i8** %8
%49 = call i32 @free(i8* %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%51 = call i32 @fflush(i32* null)
%52 = load i32, i32* %5
store i32 %52, i32* %1
br label %210
53: ; preds = %44
%54 = call i32 @chdir_test(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%55 = call i32 @expect_zng(i32 0, i32 %54)
store i32 %55, i32* %5
%56 = load i32, i32* %5
%57 = icmp ne i32 %56, 0
br i1 %57, label %58, label %61
58: ; preds = %53
%59 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%60 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %61
61: ; preds = %58, %53
%62 = call i8* @getcwd_test(i32* null, i32 8192)
store i8* %62, i8** %9
%63 = call i32 @expect_ptr(i32 0, i8* %62)
store i32 %63, i32* %5
%64 = load i32, i32* %5
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %61
%67 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%68 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %69
69: ; preds = %66, %61
%70 = load i32, i32* %5
%71 = icmp eq i32 %70, -1
br i1 %71, label %72, label %78
72: ; preds = %69
%73 = load i8*, i8** %8
%74 = call i32 @free(i8* %73)
%75 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%76 = call i32 @fflush(i32* null)
%77 = load i32, i32* %5
store i32 %77, i32* %1
br label %210
78: ; preds = %69
%79 = load i8*, i8** %8
%80 = load i8*, i8** %9
%81 = call i64 @strcmp(i8* %79, i8* %80)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %78
%84 = call i32 @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0))
%85 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %86
86: ; preds = %83, %78
%87 = load i8*, i8** %9
%88 = icmp ne i8* %87, null
br i1 %88, label %89, label %92
89: ; preds = %86
%90 = load i8*, i8** %9
%91 = call i32 @free(i8* %90)
br label %92
92: ; preds = %89, %86
%93 = load i8*, i8** %7
%94 = load i32, i32* @F_OK
%95 = call i32 @access_test(i8* %93, i32 %94)
%96 = call i32 @expect_zng(i32 -1, i32 %95)
store i32 %96, i32* %5
%97 = load i32, i32* %5
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %102
99: ; preds = %92
%100 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%101 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %102
102: ; preds = %99, %92
%103 = load i8*, i8** %7
%104 = load i32, i32* @O_RDWR
%105 = load i32, i32* @O_TRUNC
%106 = or i32 %104, %105
%107 = load i32, i32* @O_CREAT
%108 = or i32 %106, %107
%109 = load i32, i32* @S_IRWXU
%110 = call i32 @open_test(i8* %103, i32 %108, i32 %109)
store i32 %110, i32* %4
%111 = call i32 @expect_gez(i32 0, i32 %110)
store i32 %111, i32* %5
%112 = load i32, i32* %5
%113 = icmp ne i32 %112, 0
br i1 %113, label %114, label %117
114: ; preds = %102
%115 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%116 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %117
117: ; preds = %114, %102
%118 = load i32, i32* %5
%119 = icmp eq i32 %118, -1
br i1 %119, label %120, label %126
120: ; preds = %117
%121 = load i8*, i8** %8
%122 = call i32 @free(i8* %121)
%123 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%124 = call i32 @fflush(i32* null)
%125 = load i32, i32* %5
store i32 %125, i32* %1
br label %210
126: ; preds = %117
%127 = load i8*, i8** %7
%128 = load i32, i32* @F_OK
%129 = call i32 @access_test(i8* %127, i32 %128)
%130 = call i32 @expect_zng(i32 0, i32 %129)
store i32 %130, i32* %5
%131 = load i32, i32* %5
%132 = icmp ne i32 %131, 0
br i1 %132, label %133, label %136
133: ; preds = %126
%134 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%135 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %136
136: ; preds = %133, %126
%137 = load i32, i32* %4
%138 = call i32 @close_test(i32 %137)
%139 = call i32 @expect_zng(i32 0, i32 %138)
store i32 %139, i32* %5
%140 = load i32, i32* %5
%141 = icmp ne i32 %140, 0
br i1 %141, label %142, label %145
142: ; preds = %136
%143 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%144 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %145
145: ; preds = %142, %136
%146 = load i8*, i8** %7
%147 = call i32 @unlink_test(i8* %146)
%148 = call i32 @expect_zng(i32 0, i32 %147)
store i32 %148, i32* %5
%149 = load i32, i32* %5
%150 = icmp ne i32 %149, 0
br i1 %150, label %151, label %154
151: ; preds = %145
%152 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%153 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %154
154: ; preds = %151, %145
%155 = load i8*, i8** %8
%156 = call i32 @chdir_test(i8* %155)
%157 = call i32 @expect_zng(i32 0, i32 %156)
store i32 %157, i32* %5
%158 = load i32, i32* %5
%159 = icmp ne i32 %158, 0
br i1 %159, label %160, label %163
160: ; preds = %154
%161 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%162 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %163
163: ; preds = %160, %154
%164 = load i8*, i8** %7
%165 = load i32, i32* @F_OK
%166 = call i32 @access_test(i8* %164, i32 %165)
%167 = call i32 @expect_zng(i32 0, i32 %166)
store i32 %167, i32* %5
%168 = load i32, i32* %5
%169 = icmp ne i32 %168, 0
br i1 %169, label %170, label %173
170: ; preds = %163
%171 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%172 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %173
173: ; preds = %170, %163
%174 = load i32, i32* %3
%175 = call i32 @close_test(i32 %174)
%176 = call i32 @expect_zng(i32 0, i32 %175)
store i32 %176, i32* %5
%177 = load i32, i32* %5
%178 = icmp ne i32 %177, 0
br i1 %178, label %179, label %182
179: ; preds = %173
%180 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%181 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %182
182: ; preds = %179, %173
%183 = load i8*, i8** %7
%184 = call i32 @unlink_test(i8* %183)
%185 = call i32 @expect_zng(i32 0, i32 %184)
store i32 %185, i32* %5
%186 = load i32, i32* %5
%187 = icmp ne i32 %186, 0
br i1 %187, label %188, label %191
188: ; preds = %182
%189 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%190 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %191
191: ; preds = %188, %182
%192 = load i8*, i8** %7
%193 = load i32, i32* @F_OK
%194 = call i32 @access_test(i8* %192, i32 %193)
%195 = call i32 @expect_zng(i32 -1, i32 %194)
store i32 %195, i32* %5
%196 = load i32, i32* %5
%197 = icmp ne i32 %196, 0
br i1 %197, label %198, label %201
198: ; preds = %191
%199 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%200 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %201
201: ; preds = %198, %191
%202 = load i8*, i8** %8
%203 = icmp ne i8* %202, null
br i1 %203, label %204, label %207
204: ; preds = %201
%205 = load i8*, i8** %8
%206 = call i32 @free(i8* %205)
br label %207
207: ; preds = %204, %201
%208 = call i32 (...) @testbreak()
%209 = load i32, i32* %6
store i32 %209, i32* %1
br label %210
210: ; preds = %207, %120, %72, %47, %25
%211 = load i32, i32* %1
ret i32 %211
}

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