#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 scalar_t__ uid_t;
struct stat {
  int st_mode;
  scalar_t__ st_gid;
  scalar_t__ st_uid;
};
struct passwd {
  char *pw_name;
};
struct group {
  char *gr_name;
};
typedef int /*<<< orphan*/ my_uname;
typedef int /*<<< orphan*/ my_gname;
typedef int mode_t;
typedef scalar_t__ gid_t;
typedef int /*<<< orphan*/ file_uname;
typedef int /*<<< orphan*/ file_gname;

/* Variables and functions */
int EACCES;
int ELOOP;
int ENOENT;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWGRP;
int S_IWOTH;
int S_IWUSR;
int errno;
scalar_t__ getgid();
struct group *getgrgid(scalar_t__);
struct passwd *getpwuid(scalar_t__);
scalar_t__ getuid();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int stat(char const *, struct stat *);
void report_open_error(const char *filename, int err) {
  struct stat info;
  uid_t my_uid;
  gid_t my_gid;
  char my_uname[64], my_gname[64], file_uname[64], file_gname[64];
  struct passwd *p;
  struct group *g;
  mode_t perm;
  int r, perm_ok = 0;
  printf("\r\n");
  printf("Unable to open \"%s\"\r\n", filename);
  if (err == EACCES) {
    printf("You don't have permission to access %s\r\n", filename);
  }
  r = stat(filename, &info);
  if (r < 0) {
    if (errno == ENOENT) {
      printf("file %s does not exist\r\n", filename);
    } else if (errno == ELOOP) {
      printf("too many symbolic links\r\n");
    } else if (errno == EACCES) {
      printf("permission denied to get file status\r\n");
    } else {
      printf("Unable to get file status, err%d\r\n", errno);
    }
    return;
  }
  my_uid = getuid();
  my_gid = getgid();
  p = getpwuid(my_uid);
  if (p) {
    snprintf(my_uname, sizeof(my_uname), "\"%s\" (gid=%d)", p->pw_name,
             (int)my_uid);
  } else {
    snprintf(my_uname, sizeof(my_uname), "(gid=%d)", (int)my_uid);
  }
  p = getpwuid(info.st_uid);
  if (p) {
    snprintf(file_uname, sizeof(file_uname), "\"%s\" (uid=%d)", p->pw_name,
             (int)info.st_uid);
  } else {
    snprintf(file_uname, sizeof(file_uname), "(uid=%d)", (int)info.st_uid);
  }
  g = getgrgid(my_gid);
  if (g) {
    snprintf(my_gname, sizeof(my_gname), "\"%s\" (gid=%d)", g->gr_name,
             (int)my_gid);
  } else {
    snprintf(my_gname, sizeof(my_gname), "(gid=%d)", (int)my_gid);
  }
  g = getgrgid(info.st_gid);
  if (g) {
    snprintf(file_gname, sizeof(file_gname), "\"%s\" (uid=%d)", g->gr_name,
             (int)info.st_gid);
  } else {
    snprintf(file_gname, sizeof(file_gname), "(uid=%d)", (int)info.st_gid);
  }
  perm = info.st_mode;
  if ((perm & S_IROTH) && (perm & S_IWOTH)) {
    printf("%s has read/write permission for everybody\r\n", filename);
  } else {
    printf("%s is not read/write for everybody, so\r\n", filename);
    printf("  you must match either user or group permission\r\n");
    if ((perm & S_IRUSR) && (perm & S_IWUSR)) {
      printf("%s has read/write permission for user %s\r\n", filename,
             file_uname);
      perm_ok = 1;
    }
    if ((perm & S_IRGRP) && (perm & S_IWGRP)) {
      printf("%s has read/write permission for group %s\r\n", filename,
             file_gname);
      perm_ok = 1;
    }
    if (perm_ok == 0) {
      printf("%s does not read/write permission for user or group!\r\n",
             filename);
    } else {
      printf("Your access privs: user %s, group %s\r\n", my_uname, my_gname);
    }
  }
  printf("\r\n");
}


x86 assembly (clang, -O0):
<report_open_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x160,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x15c(%rbp)
lea    0x1059(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xc(%rbp),%eax
mov    0x2e22(%rip),%rcx
cmp    (%rcx),%eax
jne    11d0 <report_open_error+0x60>
mov    -0x8(%rbp),%rsi
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1080 <stat@plt>
mov    %eax,-0x158(%rbp)
cmpl   $0x0,-0x158(%rbp)
jge    129b <report_open_error+0x12b>
mov    0x2dc9(%rip),%rax
mov    (%rax),%eax
mov    0x2d98(%rip),%rcx
cmp    (%rcx),%eax
jne    121f <report_open_error+0xaf>
mov    -0x8(%rbp),%rsi
lea    0xe2c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1296 <report_open_error+0x126>
mov    0x2d9a(%rip),%rax
mov    (%rax),%eax
mov    0x2da1(%rip),%rcx
cmp    (%rcx),%eax
jne    124a <report_open_error+0xda>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1291 <report_open_error+0x121>
mov    0x2d6f(%rip),%rax
mov    (%rax),%eax
mov    0x2d7e(%rip),%rcx
cmp    (%rcx),%eax
jne    1275 <report_open_error+0x105>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    128c <report_open_error+0x11c>
mov    0x2d44(%rip),%rax
mov    (%rax),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1291 <report_open_error+0x121>
jmp    1296 <report_open_error+0x126>
jmp    15c9 <report_open_error+0x459>
mov    $0x0,%al
call   1040 <getuid@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1090 <getgid@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <getpwuid@plt>
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x148(%rbp)
je     12fc <report_open_error+0x18c>
lea    -0x80(%rbp),%rdi
mov    -0x148(%rbp),%rax
mov    (%rax),%rcx
mov    -0x30(%rbp),%rax
mov    %eax,%r8d
mov    $0x40,%esi
lea    0xdcc(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
jmp    1319 <report_open_error+0x1a9>
lea    -0x80(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    %eax,%ecx
mov    $0x40,%esi
lea    0xdaf(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <getpwuid@plt>
mov    %rax,-0x148(%rbp)
cmpq   $0x0,-0x148(%rbp)
je     1367 <report_open_error+0x1f7>
lea    -0x100(%rbp),%rdi
mov    -0x148(%rbp),%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %eax,%r8d
mov    $0x40,%esi
lea    0xd6f(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
jmp    1387 <report_open_error+0x217>
lea    -0x100(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    %eax,%ecx
mov    $0x40,%esi
lea    0xd4f(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    -0x38(%rbp),%rdi
call   1060 <getgrgid@plt>
mov    %rax,-0x150(%rbp)
cmpq   $0x0,-0x150(%rbp)
je     13d5 <report_open_error+0x265>
lea    -0xc0(%rbp),%rdi
mov    -0x150(%rbp),%rax
mov    (%rax),%rcx
mov    -0x38(%rbp),%rax
mov    %eax,%r8d
mov    $0x40,%esi
lea    0xcf3(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
jmp    13f5 <report_open_error+0x285>
lea    -0xc0(%rbp),%rdi
mov    -0x38(%rbp),%rax
mov    %eax,%ecx
mov    $0x40,%esi
lea    0xcd3(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <getgrgid@plt>
mov    %rax,-0x150(%rbp)
cmpq   $0x0,-0x150(%rbp)
je     1443 <report_open_error+0x2d3>
lea    -0x140(%rbp),%rdi
mov    -0x150(%rbp),%rax
mov    (%rax),%rcx
mov    -0x20(%rbp),%rax
mov    %eax,%r8d
mov    $0x40,%esi
lea    0xc93(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
jmp    1463 <report_open_error+0x2f3>
lea    -0x140(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    %eax,%ecx
mov    $0x40,%esi
lea    0xc73(%rip),%rdx
mov    $0x0,%al
call   1070 <snprintf@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x154(%rbp)
mov    -0x154(%rbp),%eax
mov    0x2b37(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     14b3 <report_open_error+0x343>
mov    -0x154(%rbp),%eax
mov    0x2aff(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     14b3 <report_open_error+0x343>
mov    -0x8(%rbp),%rsi
lea    0xc31(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    15bb <report_open_error+0x44b>
mov    -0x8(%rbp),%rsi
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xc62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x154(%rbp),%eax
mov    0x2ac8(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1526 <report_open_error+0x3b6>
mov    -0x154(%rbp),%eax
mov    0x2ae8(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1526 <report_open_error+0x3b6>
mov    -0x8(%rbp),%rsi
lea    -0x100(%rbp),%rdx
lea    0xc4c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x15c(%rbp)
mov    -0x154(%rbp),%eax
mov    0x2a85(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1579 <report_open_error+0x409>
mov    -0x154(%rbp),%eax
mov    0x2a9d(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1579 <report_open_error+0x409>
mov    -0x8(%rbp),%rsi
lea    -0x140(%rbp),%rdx
lea    0xc24(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0x1,-0x15c(%rbp)
cmpl   $0x0,-0x15c(%rbp)
jne    159d <report_open_error+0x42d>
mov    -0x8(%rbp),%rsi
lea    0xc27(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    15b6 <report_open_error+0x446>
lea    -0x80(%rbp),%rsi
lea    -0xc0(%rbp),%rdx
lea    0xc40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    15bb <report_open_error+0x44b>
lea    0xc2a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x160,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<report_open_error>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x128,%rsp
mov    %esi,%ebx
mov    %rdi,%r15
lea    0x1039(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5b(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2e22(%rip),%r14
cmp    %ebx,(%r14)
jne    11cc <report_open_error+0x4c>
lea    0xe54(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %r15,%rdi
call   1090 <stat@plt>
test   %eax,%eax
js     1221 <report_open_error+0xa1>
xor    %eax,%eax
call   1050 <getuid@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   10a0 <getgid@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1040 <getpwuid@plt>
test   %rax,%rax
je     1257 <report_open_error+0xd7>
mov    (%rax),%rcx
lea    0xe73(%rip),%rdx
lea    0xe0(%rsp),%rdi
mov    $0x40,%esi
mov    %ebx,%r8d
xor    %eax,%eax
call   1080 <snprintf@plt>
jmp    1274 <report_open_error+0xf4>
mov    0x2d98(%rip),%rax
mov    (%rax),%esi
mov    0x2d67(%rip),%rax
cmp    (%rax),%esi
jne    144c <report_open_error+0x2cc>
lea    0xdff(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <printf@plt>
lea    0xe22(%rip),%rdx
lea    0xe0(%rsp),%rdi
mov    $0x40,%esi
mov    %ebx,%ecx
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    0x18(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <getpwuid@plt>
test   %rax,%rax
je     12a6 <report_open_error+0x126>
mov    (%rax),%rcx
lea    0xdf9(%rip),%rdx
lea    0x60(%rsp),%rdi
mov    $0x40,%esi
mov    %ebx,%r8d
xor    %eax,%eax
call   1080 <snprintf@plt>
jmp    12c0 <report_open_error+0x140>
lea    0xde1(%rip),%rdx
lea    0x60(%rsp),%rdi
mov    $0x40,%esi
mov    %ebx,%ecx
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    %r14,%rdi
call   1070 <getgrgid@plt>
test   %rax,%rax
je     12f0 <report_open_error+0x170>
mov    (%rax),%rcx
lea    0xda4(%rip),%rdx
lea    0xa0(%rsp),%rdi
mov    $0x40,%esi
mov    %r14d,%r8d
xor    %eax,%eax
call   1080 <snprintf@plt>
jmp    130e <report_open_error+0x18e>
lea    0xd89(%rip),%rdx
lea    0xa0(%rsp),%rdi
mov    $0x40,%esi
mov    %r14d,%ecx
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <getgrgid@plt>
test   %rax,%rax
je     1340 <report_open_error+0x1c0>
mov    (%rax),%rcx
lea    0xd5f(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x40,%esi
mov    %ebx,%r8d
xor    %eax,%eax
call   1080 <snprintf@plt>
jmp    135a <report_open_error+0x1da>
lea    0xd47(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x40,%esi
mov    %ebx,%ecx
xor    %eax,%eax
call   1080 <snprintf@plt>
mov    0x8(%rsp),%ebx
mov    0x2c4b(%rip),%rax
test   %ebx,(%rax)
je     1380 <report_open_error+0x200>
mov    0x2c20(%rip),%rax
test   %ebx,(%rax)
je     1380 <report_open_error+0x200>
lea    0xd1c(%rip),%rdi
jmp    1408 <report_open_error+0x288>
lea    0xd3d(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe0a(%rip),%rdi
call   1030 <puts@plt>
mov    0x2c04(%rip),%rax
mov    $0x1,%bpl
test   %ebx,(%rax)
je     13ce <report_open_error+0x24e>
mov    0x2c2e(%rip),%rax
test   %ebx,(%rax)
je     13ce <report_open_error+0x24e>
lea    0xd30(%rip),%rdi
xor    %ebp,%ebp
lea    0x60(%rsp),%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2be3(%rip),%rax
test   %ebx,(%rax)
je     13fc <report_open_error+0x27c>
mov    0x2c08(%rip),%rax
test   %ebx,(%rax)
je     13fc <report_open_error+0x27c>
lea    0xd2d(%rip),%rdi
lea    0x20(%rsp),%rdx
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1414 <report_open_error+0x294>
test   %bpl,%bpl
je     1414 <report_open_error+0x294>
lea    0xd3c(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1432 <report_open_error+0x2b2>
lea    0xd60(%rip),%rdi
lea    0xe0(%rsp),%rsi
lea    0xa0(%rsp),%rdx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xd99(%rip),%rdi
call   1030 <puts@plt>
add    $0x128,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b7d(%rip),%rax
cmp    (%rax),%esi
jne    1460 <report_open_error+0x2e0>
lea    0xd9c(%rip),%rdi
jmp    146c <report_open_error+0x2ec>
cmp    (%r14),%esi
jne    147e <report_open_error+0x2fe>
lea    0xd68(%rip),%rdi
add    $0x128,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
lea    0xbd3(%rip),%rdi
xor    %eax,%eax
add    $0x128,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <printf@plt>

LLVM IR (-O0):
%struct.stat = type { i32, i64, i64 }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [22 x i8] c"Unable to open \22%s\22\0D\0A\00"
@EACCES = global i32 0
@.str.2 = [41 x i8] c"You don't have permission to access %s\0D\0A\00"
@errno = global i32 0
@ENOENT = global i32 0
@.str.3 = [25 x i8] c"file %s does not exist\0D\0A\00"
@ELOOP = global i32 0
@.str.4 = [26 x i8] c"too many symbolic links\0D\0A\00"
@.str.5 = [39 x i8] c"permission denied to get file status\0D\0A\00"
@.str.6 = [35 x i8] c"Unable to get file status, err%d\0D\0A\00"
@.str.7 = [14 x i8] c"\22%s\22 (gid=%d)\00"
@.str.8 = [9 x i8] c"(gid=%d)\00"
@.str.9 = [14 x i8] c"\22%s\22 (uid=%d)\00"
@.str.10 = [9 x i8] c"(uid=%d)\00"
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@.str.11 = [45 x i8] c"%s has read/write permission for everybody\0D\0A\00"
@.str.12 = [41 x i8] c"%s is not read/write for everybody, so\0D\0A\00"
@.str.13 = [51 x i8] c" you must match either user or group permission\0D\0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.14 = [43 x i8] c"%s has read/write permission for user %s\0D\0A\00"
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@.str.15 = [44 x i8] c"%s has read/write permission for group %s\0D\0A\00"
@.str.16 = [55 x i8] c"%s does not read/write permission for user or group!\0D\0A\00"
@.str.17 = [39 x i8] c"Your access privs: user %s, group %s\0D\0A\00"
define void @report_open_error(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.stat
%6 = alloca i64
%7 = alloca i64
%8 = alloca [64 x i8]
%9 = alloca [64 x i8]
%10 = alloca [64 x i8]
%11 = alloca [64 x i8]
%12 = alloca %struct.passwd*
%13 = alloca %struct.group*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %16
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%18 = load i8*, i8** %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %4
%21 = load i32, i32* @EACCES
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %26
23: ; preds = %2
%24 = load i8*, i8** %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %23, %2
%27 = load i8*, i8** %3
%28 = call i32 @stat(i8* %27, %struct.stat* %5)
store i32 %28, i32* %15
%29 = load i32, i32* %15
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %56
31: ; preds = %26
%32 = load i32, i32* @errno
%33 = load i32, i32* @ENOENT
%34 = icmp eq i32 %32, %33
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = load i8*, i8** %3
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %36)
br label %55
38: ; preds = %31
%39 = load i32, i32* @errno
%40 = load i32, i32* @ELOOP
%41 = icmp eq i32 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %38
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
br label %54
44: ; preds = %38
%45 = load i32, i32* @errno
%46 = load i32, i32* @EACCES
%47 = icmp eq i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.5, i64 0, i64 0))
br label %53
50: ; preds = %44
%51 = load i32, i32* @errno
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %50, %48
br label %54
54: ; preds = %53, %42
br label %55
55: ; preds = %54, %35
br label %195
56: ; preds = %26
%57 = call i64 (...) @getuid()
store i64 %57, i64* %6
%58 = call i64 (...) @getgid()
store i64 %58, i64* %7
%59 = load i64, i64* %6
%60 = call %struct.passwd* @getpwuid(i64 %59)
store %struct.passwd* %60, %struct.passwd** %12
%61 = load %struct.passwd*, %struct.passwd** %12
%62 = icmp ne %struct.passwd* %61, null
br i1 %62, label %63, label %71
63: ; preds = %56
%64 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%65 = load %struct.passwd*, %struct.passwd** %12
%66 = getelementptr inbounds %struct.passwd, %struct.passwd* %65, i32 0, i32 0
%67 = load i8*, i8** %66
%68 = load i64, i64* %6
%69 = trunc i64 %68 to i32
%70 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %64, i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %67, i32 %69)
br label %76
71: ; preds = %56
%72 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%73 = load i64, i64* %6
%74 = trunc i64 %73 to i32
%75 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %72, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %74)
br label %76
76: ; preds = %71, %63
%77 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 2
%78 = load i64, i64* %77
%79 = call %struct.passwd* @getpwuid(i64 %78)
store %struct.passwd* %79, %struct.passwd** %12
%80 = load %struct.passwd*, %struct.passwd** %12
%81 = icmp ne %struct.passwd* %80, null
br i1 %81, label %82, label %91
82: ; preds = %76
%83 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%84 = load %struct.passwd*, %struct.passwd** %12
%85 = getelementptr inbounds %struct.passwd, %struct.passwd* %84, i32 0, i32 0
%86 = load i8*, i8** %85
%87 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 2
%88 = load i64, i64* %87
%89 = trunc i64 %88 to i32
%90 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %83, i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %86, i32 %89)
br label %97
91: ; preds = %76
%92 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%93 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 2
%94 = load i64, i64* %93
%95 = trunc i64 %94 to i32
%96 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %92, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %95)
br label %97
97: ; preds = %91, %82
%98 = load i64, i64* %7
%99 = call %struct.group* @getgrgid(i64 %98)
store %struct.group* %99, %struct.group** %13
%100 = load %struct.group*, %struct.group** %13
%101 = icmp ne %struct.group* %100, null
br i1 %101, label %102, label %110
102: ; preds = %97
%103 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%104 = load %struct.group*, %struct.group** %13
%105 = getelementptr inbounds %struct.group, %struct.group* %104, i32 0, i32 0
%106 = load i8*, i8** %105
%107 = load i64, i64* %7
%108 = trunc i64 %107 to i32
%109 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %103, i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %106, i32 %108)
br label %115
110: ; preds = %97
%111 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%112 = load i64, i64* %7
%113 = trunc i64 %112 to i32
%114 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %111, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %113)
br label %115
115: ; preds = %110, %102
%116 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 1
%117 = load i64, i64* %116
%118 = call %struct.group* @getgrgid(i64 %117)
store %struct.group* %118, %struct.group** %13
%119 = load %struct.group*, %struct.group** %13
%120 = icmp ne %struct.group* %119, null
br i1 %120, label %121, label %130
121: ; preds = %115
%122 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%123 = load %struct.group*, %struct.group** %13
%124 = getelementptr inbounds %struct.group, %struct.group* %123, i32 0, i32 0
%125 = load i8*, i8** %124
%126 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 1
%127 = load i64, i64* %126
%128 = trunc i64 %127 to i32
%129 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %122, i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %125, i32 %128)
br label %136
130: ; preds = %115
%131 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%132 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 1
%133 = load i64, i64* %132
%134 = trunc i64 %133 to i32
%135 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %131, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %134)
br label %136
136: ; preds = %130, %121
%137 = getelementptr inbounds %struct.stat, %struct.stat* %5, i32 0, i32 0
%138 = load i32, i32* %137
store i32 %138, i32* %14
%139 = load i32, i32* %14
%140 = load i32, i32* @S_IROTH
%141 = and i32 %139, %140
%142 = icmp ne i32 %141, 0
br i1 %142, label %143, label %151
143: ; preds = %136
%144 = load i32, i32* %14
%145 = load i32, i32* @S_IWOTH
%146 = and i32 %144, %145
%147 = icmp ne i32 %146, 0
br i1 %147, label %148, label %151
148: ; preds = %143
%149 = load i8*, i8** %3
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0), i8* %149)
br label %193
151: ; preds = %143, %136
%152 = load i8*, i8** %3
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.12, i64 0, i64 0), i8* %152)
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.13, i64 0, i64 0))
%155 = load i32, i32* %14
%156 = load i32, i32* @S_IRUSR
%157 = and i32 %155, %156
%158 = icmp ne i32 %157, 0
br i1 %158, label %159, label %168
159: ; preds = %151
%160 = load i32, i32* %14
%161 = load i32, i32* @S_IWUSR
%162 = and i32 %160, %161
%163 = icmp ne i32 %162, 0
br i1 %163, label %164, label %168
164: ; preds = %159
%165 = load i8*, i8** %3
%166 = getelementptr inbounds [64 x i8], [64 x i8]* %10, i64 0, i64 0
%167 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.14, i64 0, i64 0), i8* %165, i8* %166)
store i32 1, i32* %16
br label %168
168: ; preds = %164, %159, %151
%169 = load i32, i32* %14
%170 = load i32, i32* @S_IRGRP
%171 = and i32 %169, %170
%172 = icmp ne i32 %171, 0
br i1 %172, label %173, label %182
173: ; preds = %168
%174 = load i32, i32* %14
%175 = load i32, i32* @S_IWGRP
%176 = and i32 %174, %175
%177 = icmp ne i32 %176, 0
br i1 %177, label %178, label %182
178: ; preds = %173
%179 = load i8*, i8** %3
%180 = getelementptr inbounds [64 x i8], [64 x i8]* %11, i64 0, i64 0
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.15, i64 0, i64 0), i8* %179, i8* %180)
store i32 1, i32* %16
br label %182
182: ; preds = %178, %173, %168
%183 = load i32, i32* %16
%184 = icmp eq i32 %183, 0
br i1 %184, label %185, label %188
185: ; preds = %182
%186 = load i8*, i8** %3
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.16, i64 0, i64 0), i8* %186)
br label %192
188: ; preds = %182
%189 = getelementptr inbounds [64 x i8], [64 x i8]* %8, i64 0, i64 0
%190 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.17, i64 0, i64 0), i8* %189, i8* %190)
br label %192
192: ; preds = %188, %185
br label %193
193: ; preds = %192, %148
%194 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %195
195: ; preds = %193, %55
ret void
}

LLVM IR (-O2):
%struct.stat = type { i32, i64, i64 }
%struct.passwd = type { i8* }
%struct.group = type { i8* }
@.str.1 = [22 x i8] c"Unable to open \22%s\22\0D\0A\00"
@EACCES = global i32 0
@.str.2 = [41 x i8] c"You don't have permission to access %s\0D\0A\00"
@errno = global i32 0
@ENOENT = global i32 0
@.str.3 = [25 x i8] c"file %s does not exist\0D\0A\00"
@ELOOP = global i32 0
@.str.6 = [35 x i8] c"Unable to get file status, err%d\0D\0A\00"
@.str.7 = [14 x i8] c"\22%s\22 (gid=%d)\00"
@.str.8 = [9 x i8] c"(gid=%d)\00"
@.str.9 = [14 x i8] c"\22%s\22 (uid=%d)\00"
@.str.10 = [9 x i8] c"(uid=%d)\00"
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@.str.11 = [45 x i8] c"%s has read/write permission for everybody\0D\0A\00"
@.str.12 = [41 x i8] c"%s is not read/write for everybody, so\0D\0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str.14 = [43 x i8] c"%s has read/write permission for user %s\0D\0A\00"
@S_IRGRP = global i32 0
@S_IWGRP = global i32 0
@.str.15 = [44 x i8] c"%s has read/write permission for group %s\0D\0A\00"
@.str.16 = [55 x i8] c"%s does not read/write permission for user or group!\0D\0A\00"
@.str.17 = [39 x i8] c"Your access privs: user %s, group %s\0D\0A\00"
@str.18 = [50 x i8] c" you must match either user or group permission\0D\00"
@str.19 = [2 x i8] c"\0D\00"
@str.20 = [38 x i8] c"permission denied to get file status\0D\00"
@str.21 = [25 x i8] c"too many symbolic links\0D\00"
define void @report_open_error(i8* %0, i32 %1) {
%3 = alloca %struct.stat
%4 = alloca [64 x i8]
%5 = alloca [64 x i8]
%6 = alloca [64 x i8]
%7 = alloca [64 x i8]
%8 = bitcast %struct.stat* %3 to i8*
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %5, i64 0, i64 0
%11 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [64 x i8], [64 x i8]* %7, i64 0, i64 0
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.19, i64 0, i64 0))
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%15 = load i32, i32* @EACCES
%16 = icmp eq i32 %15, %1
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i8* %0)
br label %19
19: ; preds = %17, %2
%20 = call i32 @stat(i8* %0, %struct.stat* %3)
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %40
22: ; preds = %19
%23 = load i32, i32* @errno
%24 = load i32, i32* @ENOENT
%25 = icmp eq i32 %23, %24
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i8* %0)
br label %132
28: ; preds = %22
%29 = load i32, i32* @ELOOP
%30 = icmp eq i32 %23, %29
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.21, i64 0, i64 0))
br label %132
33: ; preds = %28
%34 = load i32, i32* @EACCES
%35 = icmp eq i32 %23, %34
br i1 %35, label %36, label %38
36: ; preds = %33
%37 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str.20, i64 0, i64 0))
br label %132
38: ; preds = %33
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i32 %23)
br label %132
40: ; preds = %19
%41 = tail call i64 (...) @getuid()
%42 = tail call i64 (...) @getgid()
%43 = tail call %struct.passwd* @getpwuid(i64 %41)
%44 = icmp eq %struct.passwd* %43, null
br i1 %44, label %50, label %45
45: ; preds = %40
%46 = getelementptr inbounds %struct.passwd, %struct.passwd* %43, i64 0, i32 0
%47 = load i8*, i8** %46
%48 = trunc i64 %41 to i32
%49 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %47, i32 %48)
br label %53
50: ; preds = %40
%51 = trunc i64 %41 to i32
%52 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %50, %45
%54 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 2
%55 = load i64, i64* %54
%56 = call %struct.passwd* @getpwuid(i64 %55)
%57 = icmp eq %struct.passwd* %56, null
br i1 %57, label %63, label %58
58: ; preds = %53
%59 = getelementptr inbounds %struct.passwd, %struct.passwd* %56, i64 0, i32 0
%60 = load i8*, i8** %59
%61 = trunc i64 %55 to i32
%62 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %11, i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %60, i32 %61)
br label %66
63: ; preds = %53
%64 = trunc i64 %55 to i32
%65 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %11, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %63, %58
%67 = call %struct.group* @getgrgid(i64 %42)
%68 = icmp eq %struct.group* %67, null
br i1 %68, label %74, label %69
69: ; preds = %66
%70 = getelementptr inbounds %struct.group, %struct.group* %67, i64 0, i32 0
%71 = load i8*, i8** %70
%72 = trunc i64 %42 to i32
%73 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %10, i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0), i8* %71, i32 %72)
br label %77
74: ; preds = %66
%75 = trunc i64 %42 to i32
%76 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %10, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0), i32 %75)
br label %77
77: ; preds = %74, %69
%78 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 1
%79 = load i64, i64* %78
%80 = call %struct.group* @getgrgid(i64 %79)
%81 = icmp eq %struct.group* %80, null
br i1 %81, label %87, label %82
82: ; preds = %77
%83 = getelementptr inbounds %struct.group, %struct.group* %80, i64 0, i32 0
%84 = load i8*, i8** %83
%85 = trunc i64 %79 to i32
%86 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %12, i32 64, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0), i8* %84, i32 %85)
br label %90
87: ; preds = %77
%88 = trunc i64 %79 to i32
%89 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %12, i32 64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.10, i64 0, i64 0), i32 %88)
br label %90
90: ; preds = %87, %82
%91 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%92 = load i32, i32* %91
%93 = load i32, i32* @S_IROTH
%94 = and i32 %93, %92
%95 = icmp eq i32 %94, 0
br i1 %95, label %102, label %96
96: ; preds = %90
%97 = load i32, i32* @S_IWOTH
%98 = and i32 %97, %92
%99 = icmp eq i32 %98, 0
br i1 %99, label %102, label %100
100: ; preds = %96
%101 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.11, i64 0, i64 0), i8* %0)
br label %130
102: ; preds = %96, %90
%103 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.12, i64 0, i64 0), i8* %0)
%104 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.18, i64 0, i64 0))
%105 = load i32, i32* @S_IRUSR
%106 = and i32 %105, %92
%107 = icmp eq i32 %106, 0
br i1 %107, label %114, label %108
108: ; preds = %102
%109 = load i32, i32* @S_IWUSR
%110 = and i32 %109, %92
%111 = icmp eq i32 %110, 0
br i1 %111, label %114, label %112
112: ; preds = %108
%113 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.14, i64 0, i64 0), i8* %0, i8* %11)
br label %114
114: ; preds = %112, %108, %102
%115 = phi i1 [ false, %112 ], [ true, %108 ], [ true, %102 ]
%116 = load i32, i32* @S_IRGRP
%117 = and i32 %116, %92
%118 = icmp eq i32 %117, 0
br i1 %118, label %125, label %119
119: ; preds = %114
%120 = load i32, i32* @S_IWGRP
%121 = and i32 %120, %92
%122 = icmp eq i32 %121, 0
br i1 %122, label %125, label %123
123: ; preds = %119
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.15, i64 0, i64 0), i8* %0, i8* %12)
br label %128
125: ; preds = %119, %114
br i1 %115, label %126, label %128
126: ; preds = %125
%127 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([55 x i8], [55 x i8]* @.str.16, i64 0, i64 0), i8* %0)
br label %130
128: ; preds = %123, %125
%129 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.17, i64 0, i64 0), i8* %9, i8* %10)
br label %130
130: ; preds = %126, %128, %100
%131 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.19, i64 0, i64 0))
br label %132
132: ; preds = %26, %36, %38, %31, %130
ret void
}