#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;
typedef int /*<<< orphan*/ FILE;

/* 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;
  FILE *fp;
  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    $0x2040,%rsp
lea    -0x2010(%rbp),%rdi
xor    %esi,%esi
mov    $0x2000,%edx
call   1090 <memset@plt>
movl   $0x0,-0x2028(%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,-0x202c(%rbp)
xor    %edi,%edi
call   1030 <expect_uid@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
ff ff ff
mov    $0x0,%al
call   10b0 <getgid_test@plt>
mov    %eax,%esi
mov    %esi,-0x2030(%rbp)
xor    %edi,%edi
call   1130 <expect_gid@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%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,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
ff ff ff
cmpl   $0xffffffff,-0x2024(%rbp)
jne    13ac <BasicUid+0x16c>
lea    0xca6(%rip),%rdi
call   1070 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   10f0 <fflush@plt>
mov    -0x2024(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    173c <BasicUid+0x4fc>
lea    -0x2010(%rbp),%rdi
lea    -0x2038(%rbp),%rsi
call   1140 <stat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
ff ff ff
mov    -0x202c(%rbp),%edi
mov    -0x2034(%rbp),%esi
call   1110 <expect_val@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
ff ff ff
mov    -0x2014(%rbp),%edi
mov    -0x202c(%rbp),%esi
mov    -0x2030(%rbp),%edx
call   1040 <fchown_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
ff ff ff
mov    -0x2014(%rbp),%edi
lea    -0x2038(%rbp),%rsi
call   10e0 <fstat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
ff ff ff
mov    -0x202c(%rbp),%edi
mov    -0x2034(%rbp),%esi
call   1110 <expect_val@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
ff ff ff
mov    -0x2030(%rbp),%edi
mov    -0x2038(%rbp),%esi
call   1110 <expect_val@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
ff ff ff
lea    -0x2010(%rbp),%rdi
mov    -0x202c(%rbp),%esi
mov    -0x2030(%rbp),%edx
call   1150 <chown_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
ff ff ff
lea    -0x2010(%rbp),%rdi
lea    -0x2038(%rbp),%rsi
call   1140 <stat_test@plt>
mov    %eax,%esi
xor    %edi,%edi
call   10c0 <expect_zng@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
mov    -0x202c(%rbp),%edi
mov    -0x2034(%rbp),%esi
call   1110 <expect_val@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%rbp)
ff ff ff
mov    -0x2030(%rbp),%edi
mov    -0x2038(%rbp),%esi
call   1110 <expect_val@plt>
mov    %eax,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%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,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%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,-0x2024(%rbp)
cmpl   $0x0,-0x2024(%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,-0x2028(%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,-0x2024(%rbp)
mov    $0x0,%al
call   1100 <testbreak@plt>
mov    -0x2028(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x2040,%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 i32
%9 = alloca %struct.stat
%10 = bitcast [8192 x i8]* %2 to i8*
store i32 0, i32* %6
%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 i32 (...) @getuid_test()
store i32 %14, i32* %7
%15 = call i32 @expect_uid(i32 0, i32 %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, i64 0, i64 0))
%20 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %21
21: ; preds = %18, %0
%22 = call i32 (...) @getgid_test()
store i32 %22, i32* %8
%23 = call i32 @expect_gid(i32 0, i32 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%28 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %29
29: ; preds = %26, %21
%30 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%31 = load i32, i32* @O_RDWR
%32 = load i32, i32* @O_TRUNC
%33 = or i32 %31, %32
%34 = load i32, i32* @O_CREAT
%35 = or i32 %33, %34
%36 = load i32, i32* @S_IRWXU
%37 = call i32 @open_test(i8* %30, i32 %35, i32 %36)
store i32 %37, i32* %3
%38 = call i32 @expect_gez(i32 0, i32 %37)
store i32 %38, i32* %5
%39 = load i32, i32* %5
%40 = icmp ne i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %29
%42 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%43 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %44
44: ; preds = %41, %29
%45 = load i32, i32* %5
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %51
47: ; preds = %44
%48 = call i32 @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0))
%49 = call i32 @fflush(i32* null)
%50 = load i32, i32* %5
store i32 %50, i32* %1
br label %173
51: ; preds = %44
%52 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%53 = call i32 @stat_test(i8* %52, %struct.stat* %9)
%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 = %51
%58 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%59 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %60
60: ; preds = %57, %51
%61 = load i32, i32* %7
%62 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 1
%63 = load i32, i32* %62
%64 = call i32 @expect_val(i32 %61, i32 %63)
store i32 %64, i32* %5
%65 = load i32, i32* %5
%66 = icmp ne i32 %65, 0
br i1 %66, label %67, label %70
67: ; preds = %60
%68 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%69 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %70
70: ; preds = %67, %60
%71 = load i32, i32* %3
%72 = load i32, i32* %7
%73 = load i32, i32* %8
%74 = call i32 @fchown_test(i32 %71, i32 %72, i32 %73)
%75 = call i32 @expect_zng(i32 0, i32 %74)
store i32 %75, i32* %5
%76 = load i32, i32* %5
%77 = icmp ne i32 %76, 0
br i1 %77, label %78, label %81
78: ; preds = %70
%79 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%80 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %81
81: ; preds = %78, %70
%82 = load i32, i32* %3
%83 = call i32 @fstat_test(i32 %82, %struct.stat* %9)
%84 = call i32 @expect_zng(i32 0, i32 %83)
store i32 %84, i32* %5
%85 = load i32, i32* %5
%86 = icmp ne i32 %85, 0
br i1 %86, label %87, label %90
87: ; preds = %81
%88 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%89 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %90
90: ; preds = %87, %81
%91 = load i32, i32* %7
%92 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 1
%93 = load i32, i32* %92
%94 = call i32 @expect_val(i32 %91, i32 %93)
store i32 %94, i32* %5
%95 = load i32, i32* %5
%96 = icmp ne i32 %95, 0
br i1 %96, label %97, label %100
97: ; preds = %90
%98 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%99 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %100
100: ; preds = %97, %90
%101 = load i32, i32* %8
%102 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%103 = load i32, i32* %102
%104 = call i32 @expect_val(i32 %101, i32 %103)
store i32 %104, i32* %5
%105 = load i32, i32* %5
%106 = icmp ne i32 %105, 0
br i1 %106, label %107, label %110
107: ; preds = %100
%108 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%109 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %110
110: ; preds = %107, %100
%111 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%112 = load i32, i32* %7
%113 = load i32, i32* %8
%114 = call i32 @chown_test(i8* %111, i32 %112, i32 %113)
%115 = call i32 @expect_zng(i32 0, i32 %114)
store i32 %115, i32* %5
%116 = load i32, i32* %5
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %121
118: ; preds = %110
%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* %6
br label %121
121: ; preds = %118, %110
%122 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%123 = call i32 @stat_test(i8* %122, %struct.stat* %9)
%124 = call i32 @expect_zng(i32 0, i32 %123)
store i32 %124, i32* %5
%125 = load i32, i32* %5
%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* %6
br label %130
130: ; preds = %127, %121
%131 = load i32, i32* %7
%132 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 1
%133 = load i32, i32* %132
%134 = call i32 @expect_val(i32 %131, i32 %133)
store i32 %134, i32* %5
%135 = load i32, i32* %5
%136 = icmp ne i32 %135, 0
br i1 %136, label %137, label %140
137: ; preds = %130
%138 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%139 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %140
140: ; preds = %137, %130
%141 = load i32, i32* %8
%142 = getelementptr inbounds %struct.stat, %struct.stat* %9, i32 0, i32 0
%143 = load i32, i32* %142
%144 = call i32 @expect_val(i32 %141, i32 %143)
store i32 %144, i32* %5
%145 = load i32, i32* %5
%146 = icmp ne i32 %145, 0
br i1 %146, label %147, label %150
147: ; preds = %140
%148 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%149 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %150
150: ; preds = %147, %140
%151 = load i32, i32* %3
%152 = call i32 @close_test(i32 %151)
%153 = call i32 @expect_zng(i32 0, i32 %152)
store i32 %153, i32* %5
%154 = load i32, i32* %5
%155 = icmp ne i32 %154, 0
br i1 %155, label %156, label %159
156: ; preds = %150
%157 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%158 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %159
159: ; preds = %156, %150
%160 = getelementptr inbounds [8192 x i8], [8192 x i8]* %2, i64 0, i64 0
%161 = call i32 @unlink_test(i8* %160)
%162 = call i32 @expect_zng(i32 0, i32 %161)
store i32 %162, i32* %5
%163 = load i32, i32* %5
%164 = icmp ne i32 %163, 0
br i1 %164, label %165, label %168
165: ; preds = %159
%166 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0))
%167 = call i32 @fflush(i32* null)
store i32 -1, i32* %6
br label %168
168: ; preds = %165, %159
%169 = call i32 (...) @getlogin_test()
%170 = call i32 @expect_zng(i32 0, i32 %169)
store i32 %170, i32* %5
%171 = call i32 (...) @testbreak()
%172 = load i32, i32* %6
store i32 %172, i32* %1
br label %173
173: ; preds = %168, %47
%174 = load i32, i32* %1
ret i32 %174
}

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
}