#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 st_mode;
};

/* Variables and functions */
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int S_IRWXO;
int S_IRWXU;
int /*<<< orphan*/ chmod_test(char *, int);
int /*<<< orphan*/ close_test(int);
int expect_bol(int /*<<< orphan*/, int);
int expect_gez(int /*<<< orphan*/, int);
int expect_zng(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fchmod_test(int, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fstat_test(int, struct stat *);
int open_test(char *, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stat_test(char *, struct stat *);
int /*<<< orphan*/ testbreak();
int /*<<< orphan*/ unlink_test(char *);
int /*<<< orphan*/ xtmpnam(char *);
int BasicFilePerm(void) {
  int block = 0;
  int fd;
  int passed;
  char tf[8192] = {0};
  struct stat buf;
  xtmpnam(tf);
  testbreak();
  passed =
      expect_gez(0, fd = open_test(tf, 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) {
    printf("\tFail Phase 2: Aborting test because of catastrophic failure\n");
    fflush(NULL);
    return passed;
  };
  passed = expect_zng(0, fstat_test(fd, &buf));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_bol(0, (buf.st_mode & S_IRWXU));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, fchmod_test(fd, S_IRWXO));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, fstat_test(fd, &buf));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_bol(0, (buf.st_mode & S_IRWXO));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, fchmod_test(fd, S_IRWXU));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, fstat_test(fd, &buf));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_bol(0, (buf.st_mode & S_IRWXU));
  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(tf));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  testbreak();
  passed =
      expect_gez(0, fd = open_test(tf, 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) {
    printf("\tFail Phase 2: Aborting test because of catastrophic failure\n");
    fflush(NULL);
    return passed;
  };
  passed = expect_zng(0, stat_test(tf, &buf));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_bol(0, (buf.st_mode & S_IRWXU));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, chmod_test(tf, S_IRWXO));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, stat_test(tf, &buf));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_bol(0, (buf.st_mode & S_IRWXO));
  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, chmod_test(tf, S_IRWXU));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, stat_test(tf, &buf));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_bol(0, (buf.st_mode & S_IRWXU));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, unlink_test(tf));
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  testbreak();
  return block;
}


x86 assembly (clang, -O0):
<BasicFilePerm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
movl   $0x0,-0x8(%rbp)
lea    -0x2010(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1070 <memset@plt>
lea    -0x2010(%rbp),%rdi
call   1040 <xtmpnam@plt>
mov    $0x0,%al
call   10c0 <testbreak@plt>
lea    -0x2010(%rbp),%rdi
mov    0x2d92(%rip),%rax
mov    (%rax),%esi
mov    0x2db1(%rip),%rax
or     (%rax),%esi
mov    0x2db0(%rip),%rax
or     (%rax),%esi
mov    0x2d7f(%rip),%rax
mov    (%rax),%edx
call   1080 <open_test@plt>
mov    %eax,%esi
mov    %esi,-0xc(%rbp)
xor    %edi,%edi
call   1100 <expect_gez@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     128d <BasicFilePerm+0x9d>
lea    0xd88(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    12b7 <BasicFilePerm+0xc7>
lea    0xd98(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    186a <BasicFilePerm+0x67a>
mov    -0xc(%rbp),%edi
lea    -0x2018(%rbp),%rsi
call   10a0 <fstat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     12f8 <BasicFilePerm+0x108>
lea    0xd1d(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0x2018(%rbp),%esi
mov    0x2ccb(%rip),%rax
and    (%rax),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1337 <BasicFilePerm+0x147>
lea    0xcde(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2c9f(%rip),%rax
mov    (%rax),%esi
call   1030 <fchmod_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     137a <BasicFilePerm+0x18a>
lea    0xc9b(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x2018(%rbp),%rsi
call   10a0 <fstat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     13bb <BasicFilePerm+0x1cb>
lea    0xc5a(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0x2018(%rbp),%esi
mov    0x2c18(%rip),%rax
and    (%rax),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     13fa <BasicFilePerm+0x20a>
lea    0xc1b(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2bcc(%rip),%rax
mov    (%rax),%esi
call   1030 <fchmod_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     143d <BasicFilePerm+0x24d>
lea    0xbd8(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x2018(%rbp),%rsi
call   10a0 <fstat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     147e <BasicFilePerm+0x28e>
lea    0xb97(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0x2018(%rbp),%esi
mov    0x2b45(%rip),%rax
and    (%rax),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     14bd <BasicFilePerm+0x2cd>
lea    0xb58(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <close_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     14f7 <BasicFilePerm+0x307>
lea    0xb1e(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
lea    -0x2010(%rbp),%rdi
call   10d0 <unlink_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1535 <BasicFilePerm+0x345>
lea    0xae0(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    $0x0,%al
call   10c0 <testbreak@plt>
lea    -0x2010(%rbp),%rdi
mov    0x2a7e(%rip),%rax
mov    (%rax),%esi
mov    0x2a9d(%rip),%rax
or     (%rax),%esi
mov    0x2a9c(%rip),%rax
or     (%rax),%esi
mov    0x2a6b(%rip),%rax
mov    (%rax),%edx
call   1080 <open_test@plt>
mov    %eax,%esi
mov    %esi,-0xc(%rbp)
xor    %edi,%edi
call   1100 <expect_gez@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     15a1 <BasicFilePerm+0x3b1>
lea    0xa74(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    15cb <BasicFilePerm+0x3db>
lea    0xa84(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    186a <BasicFilePerm+0x67a>
lea    -0x2010(%rbp),%rdi
lea    -0x2018(%rbp),%rsi
call   10f0 <stat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1610 <BasicFilePerm+0x420>
lea    0xa05(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0x2018(%rbp),%esi
mov    0x29b3(%rip),%rax
and    (%rax),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     164f <BasicFilePerm+0x45f>
lea    0x9c6(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
lea    -0x2010(%rbp),%rdi
mov    0x2983(%rip),%rax
mov    (%rax),%esi
call   1110 <chmod_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1696 <BasicFilePerm+0x4a6>
lea    0x97f(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
lea    -0x2010(%rbp),%rdi
lea    -0x2018(%rbp),%rsi
call   10f0 <stat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     16db <BasicFilePerm+0x4eb>
lea    0x93a(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0x2018(%rbp),%esi
mov    0x28f8(%rip),%rax
and    (%rax),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     171a <BasicFilePerm+0x52a>
lea    0x8fb(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <close_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1754 <BasicFilePerm+0x564>
lea    0x8c1(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
lea    -0x2010(%rbp),%rdi
mov    0x286e(%rip),%rax
mov    (%rax),%esi
call   1110 <chmod_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     179b <BasicFilePerm+0x5ab>
lea    0x87a(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
lea    -0x2010(%rbp),%rdi
lea    -0x2018(%rbp),%rsi
call   10f0 <stat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     17e0 <BasicFilePerm+0x5f0>
lea    0x835(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    -0x2018(%rbp),%esi
mov    0x27e3(%rip),%rax
and    (%rax),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     181f <BasicFilePerm+0x62f>
lea    0x7f6(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
lea    -0x2010(%rbp),%rdi
call   10d0 <unlink_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   1090 <expect_zng@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     185d <BasicFilePerm+0x66d>
lea    0x7b8(%rip),%rdi
call   1060 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10b0 <fflush@plt>
movl   $0xffffffff,-0x8(%rbp)
mov    $0x0,%al
call   10c0 <testbreak@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BasicFilePerm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2018,%rsp
lea    0x10(%rsp),%rbp
xor    %ebx,%ebx
mov    $0x2000,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1070 <memset@plt>
mov    %rbp,%rdi
call   1050 <xtmpnam@plt>
xor    %eax,%eax
call   10c0 <testbreak@plt>
mov    0x2d9b(%rip),%r12
mov    0x2dbc(%rip),%r13
mov    0x0(%r13),%esi
or     (%r12),%esi
mov    0x2db5(%rip),%rax
or     (%rax),%esi
mov    0x2d84(%rip),%r15
mov    (%r15),%edx
mov    %rbp,%rdi
call   1080 <open_test@plt>
mov    %eax,%r14d
xor    %edi,%edi
mov    %eax,%esi
call   1100 <expect_gez@plt>
test   %eax,%eax
je     128a <BasicFilePerm+0x9a>
mov    %eax,%ebp
lea    0xdcd(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%ebp
je     16a2 <BasicFilePerm+0x4b2>
lea    0x8(%rsp),%rsi
mov    %r14d,%edi
call   10a0 <fstat_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     12bc <BasicFilePerm+0xcc>
lea    0xd92(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    %r12,%rbp
mov    (%r15),%esi
and    0x8(%rsp),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
test   %eax,%eax
je     12e9 <BasicFilePerm+0xf9>
lea    0xd65(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    0x2cf0(%rip),%r12
mov    (%r12),%esi
mov    %r14d,%edi
call   1040 <fchmod_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     1321 <BasicFilePerm+0x131>
lea    0xd2d(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
lea    0x8(%rsp),%rsi
mov    %r14d,%edi
call   10a0 <fstat_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     1353 <BasicFilePerm+0x163>
lea    0xcfb(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    (%r12),%esi
and    0x8(%rsp),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
test   %eax,%eax
je     137e <BasicFilePerm+0x18e>
lea    0xcd0(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    (%r15),%esi
mov    %r14d,%edi
call   1040 <fchmod_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     13ae <BasicFilePerm+0x1be>
lea    0xca0(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
lea    0x8(%rsp),%rsi
mov    %r14d,%edi
call   10a0 <fstat_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     13e0 <BasicFilePerm+0x1f0>
lea    0xc6e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    (%r15),%esi
and    0x8(%rsp),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
test   %eax,%eax
je     140a <BasicFilePerm+0x21a>
lea    0xc44(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    %r14d,%edi
call   1060 <close_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     1437 <BasicFilePerm+0x247>
lea    0xc17(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
lea    0x10(%rsp),%rdi
call   10d0 <unlink_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     1466 <BasicFilePerm+0x276>
lea    0xbe8(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
xor    %eax,%eax
call   10c0 <testbreak@plt>
mov    0x0(%r13),%esi
or     0x0(%rbp),%esi
mov    0x2b7d(%rip),%rax
or     (%rax),%esi
mov    (%r15),%edx
lea    0x10(%rsp),%rdi
call   1080 <open_test@plt>
mov    %eax,%r14d
xor    %edi,%edi
mov    %eax,%esi
call   1100 <expect_gez@plt>
test   %eax,%eax
je     14bd <BasicFilePerm+0x2cd>
mov    %eax,%ebp
lea    0xb9a(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
cmp    $0xffffffff,%ebp
je     16a2 <BasicFilePerm+0x4b2>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10f0 <stat_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     14f1 <BasicFilePerm+0x301>
lea    0xb5d(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    (%r15),%esi
and    0x8(%rsp),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
test   %eax,%eax
je     151b <BasicFilePerm+0x32b>
lea    0xb33(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    (%r12),%esi
lea    0x10(%rsp),%rdi
call   1110 <chmod_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     154e <BasicFilePerm+0x35e>
lea    0xb00(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10f0 <stat_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     1582 <BasicFilePerm+0x392>
lea    0xacc(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    (%r12),%esi
and    0x8(%rsp),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
test   %eax,%eax
je     15ad <BasicFilePerm+0x3bd>
lea    0xaa1(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    %r14d,%edi
call   1060 <close_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     15da <BasicFilePerm+0x3ea>
lea    0xa74(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    (%r15),%esi
lea    0x10(%rsp),%rdi
call   1110 <chmod_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     160c <BasicFilePerm+0x41c>
lea    0xa42(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   10f0 <stat_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     1640 <BasicFilePerm+0x450>
lea    0xa0e(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    (%r15),%esi
and    0x8(%rsp),%esi
xor    %edi,%edi
call   10e0 <expect_bol@plt>
test   %eax,%eax
je     166a <BasicFilePerm+0x47a>
lea    0x9e4(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
lea    0x10(%rsp),%rdi
call   10d0 <unlink_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   1090 <expect_zng@plt>
test   %eax,%eax
je     1699 <BasicFilePerm+0x4a9>
lea    0x9b5(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
xor    %eax,%eax
call   10c0 <testbreak@plt>
jmp    16ba <BasicFilePerm+0x4ca>
lea    0x957(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   10b0 <fflush@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x2018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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