#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 */
typedef int /*<<< orphan*/ uid_t;
struct stat {
  int /*<<< orphan*/ st_gid;
  int /*<<< orphan*/ st_uid;
};
typedef int /*<<< orphan*/ gid_t;

/* Variables and functions */
int O_CREAT;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ S_IRWXU;
int /*<<< orphan*/ chown_test(char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ close_test(int);
int expect_gez(int /*<<< orphan*/, int);
int expect_gid(int /*<<< orphan*/, int /*<<< orphan*/);
int expect_uid(int /*<<< orphan*/, int /*<<< orphan*/);
int expect_val(int /*<<< orphan*/, int /*<<< orphan*/);
int expect_zng(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fchown_test(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
int /*<<< orphan*/ fstat_test(int, struct stat *);
int /*<<< orphan*/ getgid_test();
int /*<<< orphan*/ getlogin_test();
int /*<<< orphan*/ getuid_test();
int open_test(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stat_test(char *, struct stat *);
int /*<<< orphan*/ testbreak();
int /*<<< orphan*/ unlink_test(char *);
int /*<<< orphan*/ xtmpnam(char *);
int BasicUid(void) {
  char tf[8192] = {0};
  int fd;
  int passed;
  int block = 0;
  uid_t uid;
  gid_t gid;
  struct stat buf;
  xtmpnam(tf);
  testbreak();
  passed = expect_uid(0, uid = getuid_test());
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_gid(0, gid = getgid_test());
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  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_val(uid, buf.st_uid);
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, fchown_test(fd, uid, gid));
  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_val(uid, buf.st_uid);
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_val(gid, buf.st_gid);
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_zng(0, chown_test(tf, uid, gid));
  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_val(uid, buf.st_uid);
  if (passed != 0) {
    printf("\tFailed Phase 2: This call did something unexpected.\n");
    fflush(NULL);
    block = -1;
  };
  passed = expect_val(gid, buf.st_gid);
  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;
  };
  passed = expect_zng(0, getlogin_test());
  testbreak();
  return block;
}


x86 assembly (clang, -O0):
<BasicUid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2030,%rsp
lea    -0x2010(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1090 <memset@plt>
movl   $0x0,-0x201c(%rbp)
lea    -0x2010(%rbp),%rdi
call   1050 <xtmpnam@plt>
mov    $0x0,%al
call   1100 <testbreak@plt>
mov    $0x0,%al
call   10d0 <getuid_test@plt>
mov    %eax,%esi
mov    %esi,-0x2020(%rbp)
xor    %edi,%edi
call   1030 <expect_uid@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     12c3 <BasicUid+0x83>
lea    0xd55(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
mov    $0x0,%al
call   10b0 <getgid_test@plt>
mov    %eax,%esi
mov    %esi,-0x2024(%rbp)
xor    %edi,%edi
call   1130 <expect_gid@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     130b <BasicUid+0xcb>
lea    0xd0d(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
lea    -0x2010(%rbp),%rdi
mov    0x2cb7(%rip),%rax
mov    (%rax),%esi
mov    0x2cce(%rip),%rax
or     (%rax),%esi
mov    0x2ccd(%rip),%rax
or     (%rax),%esi
mov    0x2ca4(%rip),%rax
mov    (%rax),%edx
call   10a0 <open_test@plt>
mov    %eax,%esi
mov    %esi,-0x2014(%rbp)
xor    %edi,%edi
call   1160 <expect_gez@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     137c <BasicUid+0x13c>
lea    0xc9c(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
cmpl   $0xffffffff,-0x2018(%rbp)
jne    13ac <BasicUid+0x16c>
lea    0xca6(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
mov    -0x2018(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    173c <BasicUid+0x4fc>
lea    -0x2010(%rbp),%rdi
lea    -0x2030(%rbp),%rsi
call   1140 <stat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     13fa <BasicUid+0x1ba>
lea    0xc1e(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
mov    -0x2020(%rbp),%edi
mov    -0x202c(%rbp),%esi
call   1110 <expect_val@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     143d <BasicUid+0x1fd>
lea    0xbdb(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
mov    -0x2014(%rbp),%edi
mov    -0x2020(%rbp),%esi
mov    -0x2024(%rbp),%edx
call   1040 <fchown_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     148f <BasicUid+0x24f>
lea    0xb89(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
mov    -0x2014(%rbp),%edi
lea    -0x2030(%rbp),%rsi
call   10e0 <fstat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     14dc <BasicUid+0x29c>
lea    0xb3c(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
mov    -0x2020(%rbp),%edi
mov    -0x202c(%rbp),%esi
call   1110 <expect_val@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     151f <BasicUid+0x2df>
lea    0xaf9(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
mov    -0x2024(%rbp),%edi
mov    -0x2030(%rbp),%esi
call   1110 <expect_val@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     1562 <BasicUid+0x322>
lea    0xab6(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
lea    -0x2010(%rbp),%rdi
mov    -0x2020(%rbp),%esi
mov    -0x2024(%rbp),%edx
call   1150 <chown_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     15b5 <BasicUid+0x375>
lea    0xa63(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
lea    -0x2010(%rbp),%rdi
lea    -0x2030(%rbp),%rsi
call   1140 <stat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     1603 <BasicUid+0x3c3>
lea    0xa15(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
mov    -0x2020(%rbp),%edi
mov    -0x202c(%rbp),%esi
call   1110 <expect_val@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     1646 <BasicUid+0x406>
lea    0x9d2(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
mov    -0x2024(%rbp),%edi
mov    -0x2030(%rbp),%esi
call   1110 <expect_val@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     1689 <BasicUid+0x449>
lea    0x98f(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
mov    -0x2014(%rbp),%edi
call   1060 <close_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     16cf <BasicUid+0x48f>
lea    0x949(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
lea    -0x2010(%rbp),%rdi
call   1120 <unlink_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2018(%rbp)
cmpl   $0x0,-0x2018(%rbp)
je     1716 <BasicUid+0x4d6>
lea    0x902(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
movl   $0xffffffff,-0x201c(%rbp)
ff ff ff
mov    $0x0,%al
call   1080 <getlogin_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2018(%rbp)
mov    $0x0,%al
call   1100 <testbreak@plt>
mov    -0x201c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BasicUid>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x2010,%rsp
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
mov    $0x2000,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <memset@plt>
mov    %rbx,%rdi
call   1060 <xtmpnam@plt>
xor    %eax,%eax
call   1100 <testbreak@plt>
xor    %eax,%eax
call   10d0 <getuid_test@plt>
mov    %eax,%r12d
xor    %edi,%edi
mov    %eax,%esi
call   1030 <expect_uid@plt>
test   %eax,%eax
je     12a3 <BasicUid+0x63>
lea    0xdab(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   10b0 <getgid_test@plt>
mov    %eax,%r14d
xor    %edi,%edi
mov    %eax,%esi
call   1130 <expect_gid@plt>
test   %eax,%eax
je     12d2 <BasicUid+0x92>
lea    0xd7c(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
mov    0x2cf7(%rip),%rax
mov    0x2d10(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d0d(%rip),%rax
or     (%rax),%esi
mov    0x2ce4(%rip),%rax
mov    (%rax),%edx
lea    0x10(%rsp),%rdi
call   10a0 <open_test@plt>
mov    %eax,%r15d
xor    %edi,%edi
mov    %eax,%esi
call   1160 <expect_gez@plt>
test   %eax,%eax
je     1333 <BasicUid+0xf3>
mov    %eax,%ebx
lea    0xd24(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
cmp    $0xffffffff,%ebx
je     1572 <BasicUid+0x332>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1140 <stat_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     1367 <BasicUid+0x127>
lea    0xce7(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
mov    0xc(%rsp),%esi
mov    %r12d,%edi
call   1110 <expect_val@plt>
test   %eax,%eax
je     138f <BasicUid+0x14f>
lea    0xcbf(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
mov    %r15d,%edi
mov    %r12d,%esi
mov    %r14d,%edx
call   1040 <fchown_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     13c2 <BasicUid+0x182>
lea    0xc8c(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
lea    0x8(%rsp),%rsi
mov    %r15d,%edi
call   10e0 <fstat_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     13f4 <BasicUid+0x1b4>
lea    0xc5a(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
mov    0xc(%rsp),%esi
mov    %r12d,%edi
call   1110 <expect_val@plt>
test   %eax,%eax
je     141c <BasicUid+0x1dc>
lea    0xc32(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
mov    0x8(%rsp),%esi
mov    %r14d,%edi
call   1110 <expect_val@plt>
test   %eax,%eax
je     1444 <BasicUid+0x204>
lea    0xc0a(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
lea    0x10(%rsp),%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1150 <chown_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     1479 <BasicUid+0x239>
lea    0xbd5(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1140 <stat_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     14ad <BasicUid+0x26d>
lea    0xba1(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
mov    0xc(%rsp),%esi
mov    %r12d,%edi
call   1110 <expect_val@plt>
test   %eax,%eax
je     14d5 <BasicUid+0x295>
lea    0xb79(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
mov    0x8(%rsp),%esi
mov    %r14d,%edi
call   1110 <expect_val@plt>
test   %eax,%eax
je     14fd <BasicUid+0x2bd>
lea    0xb51(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
mov    %r15d,%edi
call   1070 <close_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     152a <BasicUid+0x2ea>
lea    0xb24(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
lea    0x10(%rsp),%rdi
call   1120 <unlink_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
test   %eax,%eax
je     1559 <BasicUid+0x319>
lea    0xaf5(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
xor    %eax,%eax
call   1080 <getlogin_test@plt>
xor    %edi,%edi
mov    %eax,%esi
call   10c0 <expect_zng@plt>
xor    %eax,%eax
call   1100 <testbreak@plt>
jmp    158a <BasicUid+0x34a>
lea    0xa87(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10f0 <fflush@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x2010,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32, i32 }
@.str = [54 x i8] c"\09Failed Phase 2: This call did something unexpected.\0A\00"
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@S_IRWXU = global i32 0
@.str.1 = [62 x i8] c"\09Fail Phase 2: Aborting test because of catastrophic failure\0A\00"
define i32 @BasicUid() {
%1 = alloca i32
%2 = alloca [8192 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.stat
%9 = bitcast [8192 x i8]* %2 to i8*
store i32 0, i32* %5
%10 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%11 = call i32 @xtmpnam(i8* %10)
%12 = call i32 (...) @testbreak()
%13 = call i32 (...) @getuid_test()
store i32 %13, i32* %6
%14 = call i32 @expect_uid(i32 0, i32 %13)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %20
17: ; preds = %0
%18 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %20
20: ; preds = %17, %0
%21 = call i32 (...) @getgid_test()
store i32 %21, i32* %7
%22 = call i32 @expect_gid(i32 0, i32 %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %28
28: ; preds = %25, %20
%29 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%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* %4
%38 = load i32, i32* %4
%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, i64 0, i64 0))
%42 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %43
43: ; preds = %40, %28
%44 = load i32, i32* %4
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %50
46: ; preds = %43
%47 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
%48 = call i32 @fflush(i32* null)
%49 = load i32, i32* %4
store i32 %49, i32* %1
br label %172
50: ; preds = %43
%51 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%52 = call i32 @stat_test(i8* %51, %struct.stat* %8)
%53 = call i32 @expect_zng(i32 0, i32 %52)
store i32 %53, i32* %4
%54 = load i32, i32* %4
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %59
56: ; preds = %50
%57 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%58 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %59
59: ; preds = %56, %50
%60 = load i32, i32* %6
%61 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%62 = load i32, i32* %61
%63 = call i32 @expect_val(i32 %60, i32 %62)
store i32 %63, i32* %4
%64 = load i32, i32* %4
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%68 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %69
69: ; preds = %66, %59
%70 = load i32, i32* %3
%71 = load i32, i32* %6
%72 = load i32, i32* %7
%73 = call i32 @fchown_test(i32 %70, i32 %71, i32 %72)
%74 = call i32 @expect_zng(i32 0, i32 %73)
store i32 %74, i32* %4
%75 = load i32, i32* %4
%76 = icmp ne i32 %75, 0
br i1 %76, label %77, label %80
77: ; preds = %69
%78 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%79 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %80
80: ; preds = %77, %69
%81 = load i32, i32* %3
%82 = call i32 @fstat_test(i32 %81, %struct.stat* %8)
%83 = call i32 @expect_zng(i32 0, i32 %82)
store i32 %83, i32* %4
%84 = load i32, i32* %4
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %89
86: ; preds = %80
%87 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%88 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %89
89: ; preds = %86, %80
%90 = load i32, i32* %6
%91 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%92 = load i32, i32* %91
%93 = call i32 @expect_val(i32 %90, i32 %92)
store i32 %93, i32* %4
%94 = load i32, i32* %4
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %89
%97 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%98 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %99
99: ; preds = %96, %89
%100 = load i32, i32* %7
%101 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%102 = load i32, i32* %101
%103 = call i32 @expect_val(i32 %100, i32 %102)
store i32 %103, i32* %4
%104 = load i32, i32* %4
%105 = icmp ne i32 %104, 0
br i1 %105, label %106, label %109
106: ; preds = %99
%107 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%108 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %109
109: ; preds = %106, %99
%110 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%111 = load i32, i32* %6
%112 = load i32, i32* %7
%113 = call i32 @chown_test(i8* %110, i32 %111, i32 %112)
%114 = call i32 @expect_zng(i32 0, i32 %113)
store i32 %114, i32* %4
%115 = load i32, i32* %4
%116 = icmp ne i32 %115, 0
br i1 %116, label %117, label %120
117: ; preds = %109
%118 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%119 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %120
120: ; preds = %117, %109
%121 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%122 = call i32 @stat_test(i8* %121, %struct.stat* %8)
%123 = call i32 @expect_zng(i32 0, i32 %122)
store i32 %123, i32* %4
%124 = load i32, i32* %4
%125 = icmp ne i32 %124, 0
br i1 %125, label %126, label %129
126: ; preds = %120
%127 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%128 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %129
129: ; preds = %126, %120
%130 = load i32, i32* %6
%131 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 1
%132 = load i32, i32* %131
%133 = call i32 @expect_val(i32 %130, i32 %132)
store i32 %133, i32* %4
%134 = load i32, i32* %4
%135 = icmp ne i32 %134, 0
br i1 %135, label %136, label %139
136: ; preds = %129
%137 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%138 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %139
139: ; preds = %136, %129
%140 = load i32, i32* %7
%141 = getelementptr inbounds %struct.stat, %struct.stat* %8, i32 0, i32 0
%142 = load i32, i32* %141
%143 = call i32 @expect_val(i32 %140, i32 %142)
store i32 %143, i32* %4
%144 = load i32, i32* %4
%145 = icmp ne i32 %144, 0
br i1 %145, label %146, label %149
146: ; preds = %139
%147 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%148 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %149
149: ; preds = %146, %139
%150 = load i32, i32* %3
%151 = call i32 @close_test(i32 %150)
%152 = call i32 @expect_zng(i32 0, i32 %151)
store i32 %152, i32* %4
%153 = load i32, i32* %4
%154 = icmp ne i32 %153, 0
br i1 %154, label %155, label %158
155: ; preds = %149
%156 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%157 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %158
158: ; preds = %155, %149
%159 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%160 = call i32 @unlink_test(i8* %159)
%161 = call i32 @expect_zng(i32 0, i32 %160)
store i32 %161, i32* %4
%162 = load i32, i32* %4
%163 = icmp ne i32 %162, 0
br i1 %163, label %164, label %167
164: ; preds = %158
%165 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%166 = call i32 @fflush(i32* null)
store i32 -1, i32* %5
br label %167
167: ; preds = %164, %158
%168 = call i32 (...) @getlogin_test()
%169 = call i32 @expect_zng(i32 0, i32 %168)
store i32 %169, i32* %4
%170 = call i32 (...) @testbreak()
%171 = load i32, i32* %5
store i32 %171, i32* %1
br label %172
172: ; preds = %167, %46
%173 = load i32, i32* %1
ret i32 %173
}

LLVM IR (-O2):
%struct.stat = type { i32, i32 }
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@S_IRWXU = global i32 0
@str.13 = [61 x i8] c"\09Fail Phase 2: Aborting test because of catastrophic failure\00"
@str.16 = [53 x i8] c"\09Failed Phase 2: This call did something unexpected.\00"
define i32 @BasicUid() {
%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 = call i32 (...) @getuid_test()
%8 = call i32 @expect_uid(i32 0, i32 %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%12 = call i32 @fflush(i32* null)
br label %13
13: ; preds = %10, %0
%14 = phi i32 [ -1, %10 ], [ 0, %0 ]
%15 = call i32 (...) @getgid_test()
%16 = call i32 @expect_gid(i32 0, i32 %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%20 = call i32 @fflush(i32* null)
br label %21
21: ; preds = %18, %13
%22 = phi i32 [ -1, %18 ], [ %14, %13 ]
%23 = load i32, i32* @O_RDWR
%24 = load i32, i32* @O_TRUNC
%25 = or i32 %24, %23
%26 = load i32, i32* @O_CREAT
%27 = or i32 %25, %26
%28 = load i32, i32* @S_IRWXU
%29 = call i32 @open_test(i8* %3, i32 %27, i32 %28)
%30 = call i32 @expect_gez(i32 0, i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %39, label %32
32: ; preds = %21
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%34 = call i32 @fflush(i32* null)
%35 = icmp eq i32 %30, -1
br i1 %35, label %36, label %39
36: ; preds = %32
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.13, i64 0, i64 0))
%38 = call i32 @fflush(i32* null)
br label %142
39: ; preds = %21, %32
%40 = phi i32 [ -1, %32 ], [ %22, %21 ]
%41 = call i32 @stat_test(i8* %3, %struct.stat* %2)
%42 = call i32 @expect_zng(i32 0, i32 %41)
%43 = icmp eq i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %39
%45 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%46 = call i32 @fflush(i32* null)
br label %47
47: ; preds = %44, %39
%48 = phi i32 [ -1, %44 ], [ %40, %39 ]
%49 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 1
%50 = load i32, i32* %49
%51 = call i32 @expect_val(i32 %7, i32 %50)
%52 = icmp eq i32 %51, 0
br i1 %52, label %56, label %53
53: ; preds = %47
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%55 = call i32 @fflush(i32* null)
br label %56
56: ; preds = %53, %47
%57 = phi i32 [ -1, %53 ], [ %48, %47 ]
%58 = call i32 @fchown_test(i32 %29, i32 %7, i32 %15)
%59 = call i32 @expect_zng(i32 0, i32 %58)
%60 = icmp eq i32 %59, 0
br i1 %60, label %64, label %61
61: ; preds = %56
%62 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%63 = call i32 @fflush(i32* null)
br label %64
64: ; preds = %61, %56
%65 = phi i32 [ -1, %61 ], [ %57, %56 ]
%66 = call i32 @fstat_test(i32 %29, %struct.stat* %2)
%67 = call i32 @expect_zng(i32 0, i32 %66)
%68 = icmp eq i32 %67, 0
br i1 %68, label %72, label %69
69: ; preds = %64
%70 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%71 = call i32 @fflush(i32* null)
br label %72
72: ; preds = %69, %64
%73 = phi i32 [ -1, %69 ], [ %65, %64 ]
%74 = load i32, i32* %49
%75 = call i32 @expect_val(i32 %7, i32 %74)
%76 = icmp eq i32 %75, 0
br i1 %76, label %80, label %77
77: ; preds = %72
%78 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%79 = call i32 @fflush(i32* null)
br label %80
80: ; preds = %77, %72
%81 = phi i32 [ -1, %77 ], [ %73, %72 ]
%82 = getelementptr inbounds %struct.stat, %struct.stat* %2, i64 0, i32 0
%83 = load i32, i32* %82
%84 = call i32 @expect_val(i32 %15, i32 %83)
%85 = icmp eq i32 %84, 0
br i1 %85, label %89, label %86
86: ; preds = %80
%87 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%88 = call i32 @fflush(i32* null)
br label %89
89: ; preds = %86, %80
%90 = phi i32 [ -1, %86 ], [ %81, %80 ]
%91 = call i32 @chown_test(i8* %3, i32 %7, i32 %15)
%92 = call i32 @expect_zng(i32 0, i32 %91)
%93 = icmp eq i32 %92, 0
br i1 %93, label %97, label %94
94: ; preds = %89
%95 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%96 = call i32 @fflush(i32* null)
br label %97
97: ; preds = %94, %89
%98 = phi i32 [ -1, %94 ], [ %90, %89 ]
%99 = call i32 @stat_test(i8* %3, %struct.stat* %2)
%100 = call i32 @expect_zng(i32 0, i32 %99)
%101 = icmp eq i32 %100, 0
br i1 %101, label %105, label %102
102: ; preds = %97
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%104 = call i32 @fflush(i32* null)
br label %105
105: ; preds = %102, %97
%106 = phi i32 [ -1, %102 ], [ %98, %97 ]
%107 = load i32, i32* %49
%108 = call i32 @expect_val(i32 %7, i32 %107)
%109 = icmp eq i32 %108, 0
br i1 %109, label %113, label %110
110: ; preds = %105
%111 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%112 = call i32 @fflush(i32* null)
br label %113
113: ; preds = %110, %105
%114 = phi i32 [ -1, %110 ], [ %106, %105 ]
%115 = load i32, i32* %82
%116 = call i32 @expect_val(i32 %15, i32 %115)
%117 = icmp eq i32 %116, 0
br i1 %117, label %121, label %118
118: ; preds = %113
%119 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%120 = call i32 @fflush(i32* null)
br label %121
121: ; preds = %118, %113
%122 = phi i32 [ -1, %118 ], [ %114, %113 ]
%123 = call i32 @close_test(i32 %29)
%124 = call i32 @expect_zng(i32 0, i32 %123)
%125 = icmp eq i32 %124, 0
br i1 %125, label %129, label %126
126: ; preds = %121
%127 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%128 = call i32 @fflush(i32* null)
br label %129
129: ; preds = %126, %121
%130 = phi i32 [ -1, %126 ], [ %122, %121 ]
%131 = call i32 @unlink_test(i8* %3)
%132 = call i32 @expect_zng(i32 0, i32 %131)
%133 = icmp eq i32 %132, 0
br i1 %133, label %137, label %134
134: ; preds = %129
%135 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.16, i64 0, i64 0))
%136 = call i32 @fflush(i32* null)
br label %137
137: ; preds = %134, %129
%138 = phi i32 [ -1, %134 ], [ %130, %129 ]
%139 = call i32 (...) @getlogin_test()
%140 = call i32 @expect_zng(i32 0, i32 %139)
%141 = call i32 (...) @testbreak()
br label %142
142: ; preds = %137, %36
%143 = phi i32 [ -1, %36 ], [ %138, %137 ]
ret i32 %143
}