#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*/ uname;
typedef int /*<<< orphan*/ time_t;
struct utimbuf {
  int /*<<< orphan*/ modtime;
  int /*<<< orphan*/ actime;
};
struct tm {
  int dummy;
};
struct stat {
  int /*<<< orphan*/ st_atime;
  int /*<<< orphan*/ st_mtime;
};
struct passwd {
  int dummy;
};
struct group {
  int dummy;
};
struct flock {
  void *l_type;
  int /*<<< orphan*/ l_pid;
  scalar_t__ l_len;
  scalar_t__ l_start;
  int /*<<< orphan*/ l_whence;
};
struct dirent {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
void *F_RDLCK;
int /*<<< orphan*/ F_SETLK;
int /*<<< orphan*/ F_SETLKW;
void *F_UNLCK;
void *F_WRLCK;
int /*<<< orphan*/ O_RDWR;
int /*<<< orphan*/ R_OK;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ W_OK;
int access(char const *, int /*<<< orphan*/);
char *asctime(struct tm *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fcntl(int, int /*<<< orphan*/, struct flock *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, char *, char *,
                           char *, char *);
int /*<<< orphan*/ getpid();
struct tm *localtime(int /*<<< orphan*/ *);
int open(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ printf(char *, char *, char const *);
int stat(char const *, struct stat *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ utime(char const *, struct utimbuf *);
int main(int argc, char **argv) {
  struct flock fl;
  fl.l_type = F_WRLCK;
  fl.l_whence = SEEK_SET;
  fl.l_start = 0;
  fl.l_len = 0;
  fl.l_pid = getpid();
  int result, fd, fd2;
  time_t rawtime;
  time_t mtime;
  struct tm *timeinfo;
  time(&rawtime);
  timeinfo = localtime(&rawtime);
  const char *filename = argv[1];
  const char *filename2 = "newfile.txt";
  struct stat statbuf;
  struct utimbuf new_times;
  FILE *user;
  FILE *writefile;
  FILE *writefile2;
  char *command = "whoami";
  struct dirent *dp;
  struct passwd *pwd;
  struct group *grp;
  struct tm *tm;
  char datestring[256];
  user = popen(command, "r");
  char uname[10];
  fd = open(filename, O_RDWR), 0;
  fgets(uname, sizeof(uname) - 2, user);
  result = stat(filename, &statbuf);
  result = access(filename, W_OK);
  if (result == 0) {
    printf("%s has write access to %s\n", uname, filename);
  } else {
    printf("%s does not have write access to %s\n", uname, filename);
  }
  result = access(filename, R_OK);
  if (result == 0) {
    printf("%s has read access to %s\n", uname, filename);
  } else {
    printf("%s does not have read access to %s\n", uname, filename);
  }
  fl.l_type = F_RDLCK;
  fcntl(fd, F_SETLKW, &fl);
  fl.l_type = F_UNLCK;
  fcntl(fd, F_SETLK, &fl);
  fl.l_type = F_WRLCK;
  fcntl(fd, F_SETLKW, &fl);
  writefile = fopen(argv[1], "a+");
  fprintf(writefile, "%s %s %s %s %s", "Write time: ", asctime(timeinfo),
          "written by ", uname, "\n");
  fclose(writefile);
  fl.l_type = F_UNLCK;
  fcntl(fd, F_SETLK, &fl);
  writefile2 = fopen(filename2, "w");
  fprintf(writefile2, "%s %s %s %s %s", "Write time: ", asctime(timeinfo),
          "written by ", uname, "\n");
  fclose(writefile2);
  result = stat(filename, &statbuf);
  mtime = statbuf.st_mtime;
  new_times.actime = statbuf.st_atime;
  new_times.modtime = time(NULL);
  utime(filename, &new_times);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2da0(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    0x2d9a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1060 <getpid@plt>
mov    %eax,-0x30(%rbp)
lea    -0x48(%rbp),%rdi
call   10d0 <time@plt>
lea    -0x48(%rbp),%rdi
call   1040 <localtime@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x60(%rbp)
lea    0xd9a(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xd9b(%rip),%rax
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
lea    0xd8d(%rip),%rsi
call   1100 <popen@plt>
mov    %rax,-0x80(%rbp)
mov    -0x60(%rbp),%rdi
mov    0x2d4e(%rip),%rax
mov    (%rax),%esi
call   10e0 <open@plt>
mov    %eax,-0x40(%rbp)
lea    -0x1ca(%rbp),%rdi
mov    -0x80(%rbp),%rdx
mov    $0x8,%esi
call   10a0 <fgets@plt>
mov    -0x60(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   10c0 <stat@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x60(%rbp),%rdi
mov    0x2cfc(%rip),%rax
mov    (%rax),%esi
call   10f0 <access@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1304 <main+0x114>
lea    -0x1ca(%rbp),%rsi
mov    -0x60(%rbp),%rdx
lea    0xd1b(%rip),%rdi
call   1090 <printf@plt>
jmp    131b <main+0x12b>
lea    -0x1ca(%rbp),%rsi
mov    -0x60(%rbp),%rdx
lea    0xd1a(%rip),%rdi
call   1090 <printf@plt>
mov    -0x60(%rbp),%rdi
mov    0x2c82(%rip),%rax
mov    (%rax),%esi
call   10f0 <access@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jne    1356 <main+0x166>
lea    -0x1ca(%rbp),%rsi
mov    -0x60(%rbp),%rdx
lea    0xd09(%rip),%rdi
call   1090 <printf@plt>
jmp    136d <main+0x17d>
lea    -0x1ca(%rbp),%rsi
mov    -0x60(%rbp),%rdx
lea    0xd07(%rip),%rdi
call   1090 <printf@plt>
mov    0x2c24(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%edi
mov    0x2c5b(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <fcntl@plt>
mov    0x2c31(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%edi
mov    0x2c30(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <fcntl@plt>
mov    0x2bf6(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%edi
mov    0x2c15(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <fcntl@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xcae(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,-0x1e0(%rbp)
mov    -0x58(%rbp),%rdi
call   1080 <asctime@plt>
mov    -0x1e0(%rbp),%rdi
mov    %rax,%rcx
lea    -0x1ca(%rbp),%r9
lea    0xc76(%rip),%rsi
lea    0xc7e(%rip),%rdx
lea    0xc84(%rip),%r8
lea    0xc5c(%rip),%rax
mov    %rax,(%rsp)
call   10b0 <fprintf@plt>
mov    -0x88(%rbp),%rdi
call   1070 <fclose@plt>
mov    0x2b77(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x40(%rbp),%edi
mov    0x2b76(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <fcntl@plt>
mov    -0x68(%rbp),%rdi
lea    0xc46(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0x1d8(%rbp)
mov    -0x58(%rbp),%rdi
call   1080 <asctime@plt>
mov    -0x1d8(%rbp),%rdi
mov    %rax,%rcx
lea    -0x1ca(%rbp),%r9
lea    0xbe3(%rip),%rsi
lea    0xbeb(%rip),%rdx
lea    0xbf1(%rip),%r8
lea    0xbc9(%rip),%rax
mov    %rax,(%rsp)
call   10b0 <fprintf@plt>
mov    -0x90(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x60(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   10c0 <stat@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x6c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x70(%rbp),%eax
mov    %eax,-0x74(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   10d0 <time@plt>
mov    %eax,-0x78(%rbp)
mov    -0x60(%rbp),%rdi
lea    -0x78(%rbp),%rsi
call   1030 <utime@plt>
xor    %eax,%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsi,%r14
mov    0x2da8(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
mov    0x2da1(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x40(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x30(%rsp)
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %eax,0x28(%rsp)
lea    0x1c(%rsp),%rbx
mov    %rbx,%rdi
call   10d0 <time@plt>
mov    %rbx,%rdi
call   1040 <localtime@plt>
mov    %rax,%r12
mov    0x8(%r14),%rbx
lea    0xdb9(%rip),%rdi
lea    0xdb9(%rip),%rsi
call   1100 <popen@plt>
mov    %rax,%rbp
mov    0x2d7f(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10e0 <open@plt>
mov    %eax,%r13d
lea    0x4e(%rsp),%r15
mov    %r15,%rdi
mov    $0x8,%esi
mov    %rbp,%rdx
call   10a0 <fgets@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   10c0 <stat@plt>
mov    0x2d31(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10f0 <access@plt>
test   %eax,%eax
lea    0xd63(%rip),%rax
lea    0xd77(%rip),%rdi
cmove  %rax,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1090 <printf@plt>
mov    0x2cd9(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   10f0 <access@plt>
test   %eax,%eax
lea    0xd73(%rip),%rax
lea    0xd86(%rip),%rdi
cmove  %rax,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1090 <printf@plt>
mov    0x2c99(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
mov    0x2cd2(%rip),%rbp
mov    0x0(%rbp),%esi
lea    0x20(%rsp),%r15
mov    %r13d,%edi
mov    %r15,%rdx
call   1050 <fcntl@plt>
mov    0x2ca0(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
mov    0x2ca1(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
mov    %r15,%rdx
call   1050 <fcntl@plt>
mov    0x2c65(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
mov    0x0(%rbp),%esi
mov    %r13d,%edi
mov    %r15,%rdx
call   1050 <fcntl@plt>
mov    0x8(%r14),%rdi
lea    0xd27(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,%rbp
mov    %r12,%rdi
call   1080 <asctime@plt>
lea    0xd0e(%rip),%rcx
mov    %rcx,(%rsp)
lea    0xd08(%rip),%rsi
lea    0xd10(%rip),%rdx
lea    0xd16(%rip),%r8
mov    %rbp,%rdi
mov    %rax,%rcx
lea    0x4e(%rsp),%r14
mov    %r14,%r9
call   10b0 <fprintf@plt>
mov    %rbp,%rdi
call   1070 <fclose@plt>
mov    0x2c0a(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x20(%rsp)
mov    0x2c0b(%rip),%rax
mov    (%rax),%esi
mov    %r13d,%edi
mov    %r15,%rdx
call   1050 <fcntl@plt>
lea    0xc1f(%rip),%rdi
lea    0xcd6(%rip),%rsi
call   1110 <fopen@plt>
mov    %rax,%rbp
mov    %r12,%rdi
call   1080 <asctime@plt>
lea    0xc92(%rip),%rcx
mov    %rcx,(%rsp)
mov    %rbp,%rdi
lea    0xc89(%rip),%rsi
lea    0xc91(%rip),%rdx
mov    %rax,%rcx
lea    0xc94(%rip),%r8
mov    %r14,%r9
call   10b0 <fprintf@plt>
mov    %rbp,%rdi
call   1070 <fclose@plt>
mov    %rbx,%rdi
lea    0x10(%rsp),%rsi
call   10c0 <stat@plt>
mov    0x10(%rsp),%eax
mov    %eax,0xc(%rsp)
xor    %edi,%edi
call   10d0 <time@plt>
mov    %eax,0x8(%rsp)
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <utime@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.flock = type { i8*, i32, i64, i64, i32 }
%struct.tm = type { i32 }
%struct.stat = type { i32, i32 }
%struct.utimbuf = type { i32, i32 }
%struct.dirent = type { i32 }
%struct.passwd = type { i32 }
%struct.group = type { i32 }
@F_WRLCK = global i8* null
@SEEK_SET = global i32 0
@.str = [12 x i8] c"newfile.txt\00"
@.str.1 = [7 x i8] c"whoami\00"
@.str.2 = [2 x i8] c"r\00"
@O_RDWR = global i32 0
@W_OK = global i32 0
@.str.3 = [27 x i8] c"%s has write access to %s\0A\00"
@.str.4 = [37 x i8] c"%s does not have write access to %s\0A\00"
@R_OK = global i32 0
@.str.5 = [26 x i8] c"%s has read access to %s\0A\00"
@.str.6 = [36 x i8] c"%s does not have read access to %s\0A\00"
@F_RDLCK = global i8* null
@F_SETLKW = global i32 0
@F_UNLCK = global i8* null
@F_SETLK = global i32 0
@.str.7 = [3 x i8] c"a+\00"
@.str.8 = [15 x i8] c"%s %s %s %s %s\00"
@.str.9 = [13 x i8] c"Write time: \00"
@.str.10 = [12 x i8] c"written by \00"
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.flock
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.tm*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca %struct.stat
%16 = alloca %struct.utimbuf
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i8*
%21 = alloca %struct.dirent*
%22 = alloca %struct.passwd*
%23 = alloca %struct.group*
%24 = alloca %struct.tm*
%25 = alloca [256 x i8]
%26 = alloca [10 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%27 = load i8*, i8** @F_WRLCK
%28 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 0
store i8* %27, i8** %28
%29 = load i32, i32* @SEEK_SET
%30 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 4
store i32 %29, i32* %30
%31 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 3
store i64 0, i64* %31
%32 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 2
store i64 0, i64* %32
%33 = call i32 (...) @getpid()
%34 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 1
store i32 %33, i32* %34
%35 = call i32 @time(i32* %10)
%36 = call %struct.tm* @localtime(i32* %10)
store %struct.tm* %36, %struct.tm** %12
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 1
%39 = load i8*, i8** %38
store i8* %39, i8** %13
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %14
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %20
%40 = load i8*, i8** %20
%41 = call i32* @popen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %41, i32** %17
%42 = load i8*, i8** %13
%43 = load i32, i32* @O_RDWR
%44 = call i32 @open(i8* %42, i32 %43)
store i32 %44, i32* %8
%45 = getelementptr inbounds [10 x i8], [10 x i8]* %26, i64 0, i64 0
%46 = load i32*, i32** %17
%47 = call i32 @fgets(i8* %45, i32 8, i32* %46)
%48 = load i8*, i8** %13
%49 = call i32 @stat(i8* %48, %struct.stat* %15)
store i32 %49, i32* %7
%50 = load i8*, i8** %13
%51 = load i32, i32* @W_OK
%52 = call i32 @access(i8* %50, i32 %51)
store i32 %52, i32* %7
%53 = load i32, i32* %7
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %2
%56 = getelementptr inbounds [10 x i8], [10 x i8]* %26, i64 0, i64 0
%57 = load i8*, i8** %13
%58 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %56, i8* %57)
br label %63
59: ; preds = %2
%60 = getelementptr inbounds [10 x i8], [10 x i8]* %26, i64 0, i64 0
%61 = load i8*, i8** %13
%62 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i8* %60, i8* %61)
br label %63
63: ; preds = %59, %55
%64 = load i8*, i8** %13
%65 = load i32, i32* @R_OK
%66 = call i32 @access(i8* %64, i32 %65)
store i32 %66, i32* %7
%67 = load i32, i32* %7
%68 = icmp eq i32 %67, 0
br i1 %68, label %69, label %73
69: ; preds = %63
%70 = getelementptr inbounds [10 x i8], [10 x i8]* %26, i64 0, i64 0
%71 = load i8*, i8** %13
%72 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* %70, i8* %71)
br label %77
73: ; preds = %63
%74 = getelementptr inbounds [10 x i8], [10 x i8]* %26, i64 0, i64 0
%75 = load i8*, i8** %13
%76 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0), i8* %74, i8* %75)
br label %77
77: ; preds = %73, %69
%78 = load i8*, i8** @F_RDLCK
%79 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 0
store i8* %78, i8** %79
%80 = load i32, i32* %8
%81 = load i32, i32* @F_SETLKW
%82 = call i32 @fcntl(i32 %80, i32 %81, %struct.flock* %6)
%83 = load i8*, i8** @F_UNLCK
%84 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 0
store i8* %83, i8** %84
%85 = load i32, i32* %8
%86 = load i32, i32* @F_SETLK
%87 = call i32 @fcntl(i32 %85, i32 %86, %struct.flock* %6)
%88 = load i8*, i8** @F_WRLCK
%89 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 0
store i8* %88, i8** %89
%90 = load i32, i32* %8
%91 = load i32, i32* @F_SETLKW
%92 = call i32 @fcntl(i32 %90, i32 %91, %struct.flock* %6)
%93 = load i8**, i8*** %5
%94 = getelementptr inbounds i8*, i8** %93, i64 1
%95 = load i8*, i8** %94
%96 = call i32* @fopen(i8* %95, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
store i32* %96, i32** %18
%97 = load i32*, i32** %18
%98 = load %struct.tm*, %struct.tm** %12
%99 = call i8* @asctime(%struct.tm* %98)
%100 = getelementptr inbounds [10 x i8], [10 x i8]* %26, i64 0, i64 0
%101 = call i32 @fprintf(i32* %97, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8* %99, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %100, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%102 = load i32*, i32** %18
%103 = call i32 @fclose(i32* %102)
%104 = load i8*, i8** @F_UNLCK
%105 = getelementptr inbounds %struct.flock, %struct.flock* %6, i32 0, i32 0
store i8* %104, i8** %105
%106 = load i32, i32* %8
%107 = load i32, i32* @F_SETLK
%108 = call i32 @fcntl(i32 %106, i32 %107, %struct.flock* %6)
%109 = load i8*, i8** %14
%110 = call i32* @fopen(i8* %109, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
store i32* %110, i32** %19
%111 = load i32*, i32** %19
%112 = load %struct.tm*, %struct.tm** %12
%113 = call i8* @asctime(%struct.tm* %112)
%114 = getelementptr inbounds [10 x i8], [10 x i8]* %26, i64 0, i64 0
%115 = call i32 @fprintf(i32* %111, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8* %113, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %114, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%116 = load i32*, i32** %19
%117 = call i32 @fclose(i32* %116)
%118 = load i8*, i8** %13
%119 = call i32 @stat(i8* %118, %struct.stat* %15)
store i32 %119, i32* %7
%120 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 1
%121 = load i32, i32* %120
store i32 %121, i32* %11
%122 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%123 = load i32, i32* %122
%124 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %16, i32 0, i32 1
store i32 %123, i32* %124
%125 = call i32 @time(i32* null)
%126 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %16, i32 0, i32 0
store i32 %125, i32* %126
%127 = load i8*, i8** %13
%128 = call i32 @utime(i8* %127, %struct.utimbuf* %16)
ret i32 0
}

LLVM IR (-O2):
%struct.flock = type { i8*, i32, i64, i64, i32 }
%struct.stat = type { i32, i32 }
%struct.utimbuf = type { i32, i32 }
%struct.tm = type { i32 }
%struct.dirent = type { i32 }
%struct.passwd = type { i32 }
%struct.group = type { i32 }
@F_WRLCK = global i8* null
@SEEK_SET = global i32 0
@.str = [12 x i8] c"newfile.txt\00"
@.str.1 = [7 x i8] c"whoami\00"
@.str.2 = [2 x i8] c"r\00"
@O_RDWR = global i32 0
@W_OK = global i32 0
@.str.3 = [27 x i8] c"%s has write access to %s\0A\00"
@.str.4 = [37 x i8] c"%s does not have write access to %s\0A\00"
@R_OK = global i32 0
@.str.5 = [26 x i8] c"%s has read access to %s\0A\00"
@.str.6 = [36 x i8] c"%s does not have read access to %s\0A\00"
@F_RDLCK = global i8* null
@F_SETLKW = global i32 0
@F_UNLCK = global i8* null
@F_SETLK = global i32 0
@.str.7 = [3 x i8] c"a+\00"
@.str.8 = [15 x i8] c"%s %s %s %s %s\00"
@.str.9 = [13 x i8] c"Write time: \00"
@.str.10 = [12 x i8] c"written by \00"
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.flock
%4 = alloca i32
%5 = alloca %struct.stat
%6 = alloca %struct.utimbuf
%7 = alloca [10 x i8]
%8 = bitcast %struct.flock* %3 to i8*
%9 = load i8*, i8** @F_WRLCK
%10 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 0
store i8* %9, i8** %10
%11 = load i32, i32* @SEEK_SET
%12 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 4
store i32 %11, i32* %12
%13 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 2
%14 = bitcast i64* %13 to i8*
%15 = tail call i32 (...) @getpid()
%16 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 1
store i32 %15, i32* %16
%17 = bitcast i32* %4 to i8*
%18 = call i32 @time(i32* %4)
%19 = call %struct.tm* @localtime(i32* %4)
%20 = getelementptr inbounds i8*, i8** %1, i64 1
%21 = load i8*, i8** %20
%22 = bitcast %struct.stat* %5 to i8*
%23 = bitcast %struct.utimbuf* %6 to i8*
%24 = call i32* @popen(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%25 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%26 = load i32, i32* @O_RDWR
%27 = call i32 @open(i8* %21, i32 %26)
%28 = call i32 @fgets(i8* %25, i32 8, i32* %24)
%29 = call i32 @stat(i8* %21, %struct.stat* %5)
%30 = load i32, i32* @W_OK
%31 = call i32 @access(i8* %21, i32 %30)
%32 = icmp eq i32 %31, 0
%33 = select i1 %32, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0)
%34 = call i32 @printf(i8* %33, i8* %25, i8* %21)
%35 = load i32, i32* @R_OK
%36 = call i32 @access(i8* %21, i32 %35)
%37 = icmp eq i32 %36, 0
%38 = select i1 %37, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.6, i64 0, i64 0)
%39 = call i32 @printf(i8* %38, i8* %25, i8* %21)
%40 = load i8*, i8** @F_RDLCK
store i8* %40, i8** %10
%41 = load i32, i32* @F_SETLKW
%42 = call i32 @fcntl(i32 %27, i32 %41, %struct.flock* %3)
%43 = load i8*, i8** @F_UNLCK
store i8* %43, i8** %10
%44 = load i32, i32* @F_SETLK
%45 = call i32 @fcntl(i32 %27, i32 %44, %struct.flock* %3)
%46 = load i8*, i8** @F_WRLCK
store i8* %46, i8** %10
%47 = load i32, i32* @F_SETLKW
%48 = call i32 @fcntl(i32 %27, i32 %47, %struct.flock* %3)
%49 = load i8*, i8** %20
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%51 = call i8* @asctime(%struct.tm* %19)
%52 = call i32 @fprintf(i32* %50, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8* %51, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%53 = call i32 @fclose(i32* %50)
%54 = load i8*, i8** @F_UNLCK
store i8* %54, i8** %10
%55 = load i32, i32* @F_SETLK
%56 = call i32 @fcntl(i32 %27, i32 %55, %struct.flock* %3)
%57 = call i32* @fopen(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.12, i64 0, i64 0))
%58 = call i8* @asctime(%struct.tm* %19)
%59 = call i32 @fprintf(i32* %57, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.9, i64 0, i64 0), i8* %58, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%60 = call i32 @fclose(i32* %57)
%61 = call i32 @stat(i8* %21, %struct.stat* %5)
%62 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
%63 = load i32, i32* %62
%64 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %6, i64 0, i32 1
store i32 %63, i32* %64
%65 = call i32 @time(i32* null)
%66 = getelementptr inbounds %struct.utimbuf, %struct.utimbuf* %6, i64 0, i32 0
store i32 %65, i32* %66
%67 = call i32 @utime(i8* %21, %struct.utimbuf* %6)
ret i32 0
}