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

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
}