#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
struct flock {
  int /*<<< orphan*/ l_type;
  scalar_t__ l_len;
  scalar_t__ l_start;
  int /*<<< orphan*/ l_whence;
};
typedef int mode_t;
typedef int /*<<< orphan*/ lock;

/* Variables and functions */
int /*<<< orphan*/ F_SETLK;
int /*<<< orphan*/ F_WRLCK;
int O_CREAT;
int O_EXCL;
int O_RDWR;
int O_TRUNC;
int /*<<< orphan*/ SEEK_SET;
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_ISGID;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int);
scalar_t__ fchmod(int, int);
scalar_t__ fcntl(int, int /*<<< orphan*/, struct flock *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
int /*<<< orphan*/ memset(struct flock *, char, int);
int open(char *, int, int);
int /*<<< orphan*/ pause();
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ strlen(char *);
scalar_t__ write(int, char *, scalar_t__);
int main(int argc, char **argv) {
  int fd;
  int i, j;
  mode_t rw_mode;
  static char message[] = "hello, world\n";
  struct flock lock;
  if (argc != 2) {
    fprintf(stderr, "usage: %s file\n", argv[0]);
    exit(1);
  }
  rw_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
  fd = open(argv[1], O_RDWR | O_TRUNC | O_CREAT | O_EXCL, rw_mode);
  if (fd < 0) {
    fprintf(stderr, "%s: %s: cannot open for read/write: %s\n", argv[0],
            argv[1], strerror(errno));
    (void)close(fd);
    return 1;
  }
  if (write(fd, message, strlen(message)) != strlen(message)) {
    fprintf(stderr, "%s: %s: cannot write: %s\n", argv[0], argv[1],
            strerror(errno));
    (void)close(fd);
    return 1;
  }
  rw_mode |= S_ISGID;
  if (fchmod(fd, rw_mode) < 0) {
    fprintf(stderr, "%s: %s: cannot change mode to %o: %s\n", argv[0], argv[1],
            rw_mode, strerror(errno));
    (void)close(fd);
    return 1;
  }
  memset(&lock, '\0', sizeof(lock));
  lock.l_whence = SEEK_SET;
  lock.l_start = 0;
  lock.l_len = 0;
  lock.l_type = F_WRLCK;
  if (fcntl(fd, F_SETLK, &lock) < 0) {
    fprintf(stderr, "%s: %s: cannot lock the file: %s\n", argv[0], argv[1],
            strerror(errno));
    (void)close(fd);
    return 1;
  }
  pause();
  (void)close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11fb <main+0x4b>
mov    0x2dde(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe16(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2d7e(%rip),%rax
mov    (%rax),%eax
mov    0x2dbd(%rip),%rcx
or     (%rcx),%eax
mov    0x2d7c(%rip),%rcx
or     (%rcx),%eax
mov    0x2d6b(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2da7(%rip),%rax
mov    (%rax),%esi
mov    0x2db6(%rip),%rax
or     (%rax),%esi
mov    0x2db5(%rip),%rax
or     (%rax),%esi
mov    0x2d64(%rip),%rax
or     (%rax),%esi
mov    -0x20(%rbp),%edx
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12c4 <main+0x114>
mov    0x2d4e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x48(%rbp)
mov    0x2d13(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x54(%rbp),%edi
mov    -0x50(%rbp),%rdx
mov    -0x48(%rbp),%rcx
mov    %rax,%r8
lea    0xd67(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ea <main+0x33a>
mov    -0x14(%rbp),%eax
mov    %eax,-0x64(%rbp)
lea    0x2da7(%rip),%rdi
call   1050 <strlen@plt>
mov    -0x64(%rbp),%edi
mov    %rax,%rdx
lea    0x2d95(%rip),%rsi
call   1040 <write@plt>
mov    %rax,-0x60(%rbp)
lea    0x2d85(%rip),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x60(%rbp),%rax
cmp    %rcx,%rax
je     1369 <main+0x1b9>
mov    0x2ca9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x78(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x70(%rbp)
mov    0x2c6e(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rdx
mov    -0x70(%rbp),%rcx
mov    %rax,%r8
lea    0xcea(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ea <main+0x33a>
mov    0x2c38(%rip),%rax
mov    (%rax),%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%esi
call   10a0 <fchmod@plt>
cmp    $0x0,%rax
jge    140a <main+0x25a>
mov    0x2c24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x94(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x90(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x88(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x80(%rbp)
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0x94(%rbp),%edi
mov    -0x90(%rbp),%rdx
mov    -0x88(%rbp),%rcx
mov    -0x80(%rbp),%r8d
mov    %rax,%r9
lea    0xc63(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ea <main+0x33a>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    0x2b77(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
mov    0x2b3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2b84(%rip),%rax
mov    (%rax),%esi
lea    -0x40(%rbp),%rdx
call   1030 <fcntl@plt>
cmp    $0x0,%rax
jge    14d4 <main+0x324>
mov    0x2b50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xac(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0xa0(%rbp)
mov    0x2b0c(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
mov    -0xac(%rbp),%edi
mov    -0xa8(%rbp),%rdx
mov    -0xa0(%rbp),%rcx
mov    %rax,%r8
lea    0xbbf(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x1,-0x4(%rbp)
jmp    14ea <main+0x33a>
mov    $0x0,%al
call   1090 <pause@plt>
mov    -0x14(%rbp),%edi
call   1070 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%r12
cmp    $0x2,%edi
jne    13c7 <main+0x217>
mov    0x2db1(%rip),%rax
mov    0x2df2(%rip),%rcx
mov    (%rcx),%ebp
or     (%rax),%ebp
mov    0x2daf(%rip),%rax
or     (%rax),%ebp
mov    0x2d9e(%rip),%rax
or     (%rax),%ebp
mov    0x2de5(%rip),%rax
mov    0x2df6(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2df3(%rip),%rax
or     (%rax),%esi
mov    0x8(%r12),%rdi
mov    0x2d9d(%rip),%rax
or     (%rax),%esi
mov    %ebp,%edx
call   10b0 <open@plt>
mov    %eax,%r14d
test   %eax,%eax
js     12d7 <main+0x127>
lea    0x2e4a(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %r15,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1050 <strlen@plt>
cmp    %rax,%rbx
jne    1308 <main+0x158>
mov    0x2d49(%rip),%rax
or     (%rax),%ebp
mov    %r14d,%edi
mov    %ebp,%esi
call   10a0 <fchmod@plt>
test   %rax,%rax
js     135d <main+0x1ad>
mov    %rsp,%rbx
xor    %ebp,%ebp
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1060 <memset@plt>
mov    0x2d09(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x18(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,0x8(%rsp)
mov    0x2cd4(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    0x2d20(%rip),%rax
mov    (%rax),%esi
mov    %r14d,%edi
mov    %rbx,%rdx
call   1030 <fcntl@plt>
test   %rax,%rax
js     139b <main+0x1eb>
xor    %eax,%eax
call   1090 <pause@plt>
mov    %r14d,%edi
call   1070 <close@plt>
jmp    134e <main+0x19e>
mov    0x2cda(%rip),%rax
mov    (%rax),%ebp
mov    (%r12),%r15
mov    0x8(%r12),%rbx
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd12(%rip),%rsi
mov    %ebp,%edi
mov    %r15,%rdx
mov    %rbx,%rcx
jmp    1337 <main+0x187>
mov    0x2ca9(%rip),%rax
mov    (%rax),%ebx
mov    (%r12),%rbp
mov    0x8(%r12),%r15
mov    0x2c7f(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xd09(%rip),%rsi
mov    %ebx,%edi
mov    %rbp,%rdx
mov    %r15,%rcx
mov    %rax,%r8
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r14d,%edi
call   1070 <close@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c54(%rip),%rax
mov    (%rax),%ebx
mov    (%r12),%r15
mov    0x8(%r12),%r12
mov    0x2c2a(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xcce(%rip),%rsi
mov    %ebx,%edi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %ebp,%r8d
mov    %rax,%r9
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    1341 <main+0x191>
mov    0x2c16(%rip),%rax
mov    (%rax),%ebx
mov    (%r12),%rbp
mov    0x8(%r12),%r15
mov    0x2bec(%rip),%rax
mov    (%rax),%edi
call   10d0 <strerror@plt>
lea    0xcb6(%rip),%rsi
jmp    132f <main+0x17f>
mov    0x2bea(%rip),%rax
mov    (%rax),%edi
mov    (%r12),%rdx
lea    0xc25(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
%struct.flock = type { i32, i64, i64, i32 }
@main.message = internal global [14 x i8] c"hello, world\0A\00"
@stderr = global i32 0
@.str = [16 x i8] c"usage: %s file\0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@.str.1 = [40 x i8] c"%s: %s: cannot open for read/write: %s\0A\00"
@errno = global i32 0
@.str.2 = [26 x i8] c"%s: %s: cannot write: %s\0A\00"
@S_ISGID = global i32 0
@.str.3 = [38 x i8] c"%s: %s: cannot change mode to %o: %s\0A\00"
@SEEK_SET = global i32 0
@F_WRLCK = global i32 0
@F_SETLK = global i32 0
@.str.4 = [34 x i8] c"%s: %s: cannot lock the file: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.flock
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %20
13: ; preds = %2
%14 = load i32, i32* @stderr
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %2
%21 = load i32, i32* @S_IRUSR
%22 = load i32, i32* @S_IWUSR
%23 = or i32 %21, %22
%24 = load i32, i32* @S_IRGRP
%25 = or i32 %23, %24
%26 = load i32, i32* @S_IROTH
%27 = or i32 %25, %26
store i32 %27, i32* %9
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%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* @O_EXCL
%37 = or i32 %35, %36
%38 = load i32, i32* %9
%39 = call i32 @open(i8* %30, i32 %37, i32 %38)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %55
42: ; preds = %20
%43 = load i32, i32* @stderr
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i64 0
%46 = load i8*, i8** %45
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 1
%49 = load i8*, i8** %48
%50 = load i32, i32* @errno
%51 = call i8* @strerror(i32 %50)
%52 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %46, i8* %49, i8* %51)
%53 = load i32, i32* %6
%54 = call i32 @close(i32 %53)
store i32 1, i32* %3
br label %125
55: ; preds = %20
%56 = load i32, i32* %6
%57 = call i64 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @main.message, i64 0, i64 0))
%58 = call i64 @write(i32 %56, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @main.message, i64 0, i64 0), i64 %57)
%59 = call i64 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @main.message, i64 0, i64 0))
%60 = icmp ne i64 %58, %59
br i1 %60, label %61, label %74
61: ; preds = %55
%62 = load i32, i32* @stderr
%63 = load i8**, i8*** %5
%64 = getelementptr inbounds i8*, i8** %63, i64 0
%65 = load i8*, i8** %64
%66 = load i8**, i8*** %5
%67 = getelementptr inbounds i8*, i8** %66, i64 1
%68 = load i8*, i8** %67
%69 = load i32, i32* @errno
%70 = call i8* @strerror(i32 %69)
%71 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %65, i8* %68, i8* %70)
%72 = load i32, i32* %6
%73 = call i32 @close(i32 %72)
store i32 1, i32* %3
br label %125
74: ; preds = %55
%75 = load i32, i32* @S_ISGID
%76 = load i32, i32* %9
%77 = or i32 %76, %75
store i32 %77, i32* %9
%78 = load i32, i32* %6
%79 = load i32, i32* %9
%80 = call i64 @fchmod(i32 %78, i32 %79)
%81 = icmp slt i64 %80, 0
br i1 %81, label %82, label %96
82: ; preds = %74
%83 = load i32, i32* @stderr
%84 = load i8**, i8*** %5
%85 = getelementptr inbounds i8*, i8** %84, i64 0
%86 = load i8*, i8** %85
%87 = load i8**, i8*** %5
%88 = getelementptr inbounds i8*, i8** %87, i64 1
%89 = load i8*, i8** %88
%90 = load i32, i32* %9
%91 = load i32, i32* @errno
%92 = call i8* @strerror(i32 %91)
%93 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %86, i8* %89, i32 %90, i8* %92)
%94 = load i32, i32* %6
%95 = call i32 @close(i32 %94)
store i32 1, i32* %3
br label %125
96: ; preds = %74
%97 = call i32 @memset(%struct.flock* %10, i8 signext 0, i32 32)
%98 = load i32, i32* @SEEK_SET
%99 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 3
store i32 %98, i32* %99
%100 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 2
store i64 0, i64* %100
%101 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 1
store i64 0, i64* %101
%102 = load i32, i32* @F_WRLCK
%103 = getelementptr inbounds %struct.flock, %struct.flock* %10, i32 0, i32 0
store i32 %102, i32* %103
%104 = load i32, i32* %6
%105 = load i32, i32* @F_SETLK
%106 = call i64 @fcntl(i32 %104, i32 %105, %struct.flock* %10)
%107 = icmp slt i64 %106, 0
br i1 %107, label %108, label %121
108: ; preds = %96
%109 = load i32, i32* @stderr
%110 = load i8**, i8*** %5
%111 = getelementptr inbounds i8*, i8** %110, i64 0
%112 = load i8*, i8** %111
%113 = load i8**, i8*** %5
%114 = getelementptr inbounds i8*, i8** %113, i64 1
%115 = load i8*, i8** %114
%116 = load i32, i32* @errno
%117 = call i8* @strerror(i32 %116)
%118 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %112, i8* %115, i8* %117)
%119 = load i32, i32* %6
%120 = call i32 @close(i32 %119)
store i32 1, i32* %3
br label %125
121: ; preds = %96
%122 = call i32 (...) @pause()
%123 = load i32, i32* %6
%124 = call i32 @close(i32 %123)
store i32 0, i32* %3
br label %125
125: ; preds = %121, %108, %82, %61, %42
%126 = load i32, i32* %3
ret i32 %126
}

LLVM IR (-O2):
%struct.flock = type { i32, i64, i64, i32 }
@main.message = internal global [14 x i8] c"hello, world\0A\00"
@stderr = global i32 0
@.str = [16 x i8] c"usage: %s file\0A\00"
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@.str.1 = [40 x i8] c"%s: %s: cannot open for read/write: %s\0A\00"
@errno = global i32 0
@.str.2 = [26 x i8] c"%s: %s: cannot write: %s\0A\00"
@S_ISGID = global i32 0
@.str.3 = [38 x i8] c"%s: %s: cannot change mode to %o: %s\0A\00"
@SEEK_SET = global i32 0
@F_WRLCK = global i32 0
@F_SETLK = global i32 0
@.str.4 = [34 x i8] c"%s: %s: cannot lock the file: %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.flock
%4 = bitcast %struct.flock* %3 to i8*
%5 = icmp eq i32 %0, 2
br i1 %5, label %11, label %6
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = tail call i32 @exit(i32 1)
unreachable
11: ; preds = %2
%12 = load i32, i32* @S_IRUSR
%13 = load i32, i32* @S_IWUSR
%14 = or i32 %13, %12
%15 = load i32, i32* @S_IRGRP
%16 = or i32 %14, %15
%17 = load i32, i32* @S_IROTH
%18 = or i32 %16, %17
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = load i32, i32* @O_RDWR
%22 = load i32, i32* @O_TRUNC
%23 = or i32 %22, %21
%24 = load i32, i32* @O_CREAT
%25 = or i32 %23, %24
%26 = load i32, i32* @O_EXCL
%27 = or i32 %25, %26
%28 = tail call i32 @open(i8* %20, i32 %27, i32 %18)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %11
%31 = load i32, i32* @stderr
%32 = load i8*, i8** %1
%33 = load i8*, i8** %19
%34 = load i32, i32* @errno
%35 = tail call i8* @strerror(i32 %34)
%36 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* %32, i8* %33, i8* %35)
%37 = tail call i32 @close(i32 %28)
br label %86
38: ; preds = %11
%39 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @main.message, i64 0, i64 0))
%40 = tail call i64 @write(i32 %28, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @main.message, i64 0, i64 0), i64 %39)
%41 = tail call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @main.message, i64 0, i64 0))
%42 = icmp eq i64 %40, %41
br i1 %42, label %51, label %43
43: ; preds = %38
%44 = load i32, i32* @stderr
%45 = load i8*, i8** %1
%46 = load i8*, i8** %19
%47 = load i32, i32* @errno
%48 = tail call i8* @strerror(i32 %47)
%49 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* %45, i8* %46, i8* %48)
%50 = tail call i32 @close(i32 %28)
br label %86
51: ; preds = %38
%52 = load i32, i32* @S_ISGID
%53 = or i32 %52, %18
%54 = tail call i64 @fchmod(i32 %28, i32 %53)
%55 = icmp slt i64 %54, 0
br i1 %55, label %56, label %64
56: ; preds = %51
%57 = load i32, i32* @stderr
%58 = load i8*, i8** %1
%59 = load i8*, i8** %19
%60 = load i32, i32* @errno
%61 = tail call i8* @strerror(i32 %60)
%62 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %58, i8* %59, i32 %53, i8* %61)
%63 = tail call i32 @close(i32 %28)
br label %86
64: ; preds = %51
%65 = call i32 @memset(%struct.flock* %3, i8 signext 0, i32 32)
%66 = load i32, i32* @SEEK_SET
%67 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 3
store i32 %66, i32* %67
%68 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 1
%69 = bitcast i64* %68 to i8*
%70 = load i32, i32* @F_WRLCK
%71 = getelementptr inbounds %struct.flock, %struct.flock* %3, i64 0, i32 0
store i32 %70, i32* %71
%72 = load i32, i32* @F_SETLK
%73 = call i64 @fcntl(i32 %28, i32 %72, %struct.flock* %3)
%74 = icmp slt i64 %73, 0
br i1 %74, label %75, label %83
75: ; preds = %64
%76 = load i32, i32* @stderr
%77 = load i8*, i8** %1
%78 = load i8*, i8** %19
%79 = load i32, i32* @errno
%80 = call i8* @strerror(i32 %79)
%81 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0), i8* %77, i8* %78, i8* %80)
%82 = call i32 @close(i32 %28)
br label %86
83: ; preds = %64
%84 = call i32 (...) @pause()
%85 = call i32 @close(i32 %28)
br label %86
86: ; preds = %83, %75, %56, %43, %30
%87 = phi i32 [ 1, %30 ], [ 1, %43 ], [ 1, %56 ], [ 1, %75 ], [ 0, %83 ]
ret i32 %87
}