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

/* Variables and functions */
scalar_t__ EINTR;
scalar_t__ ENOENT;
int LINE_MAX;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int PATH_MAX;
int /*<<< orphan*/ W_OK;
int access(char *, int /*<<< orphan*/);
int /*<<< orphan*/ assert(int);
char *dirname(char *);
int /*<<< orphan*/ err(int, char *, ...);
scalar_t__ errno;
int /*<<< orphan*/ errx(int, char *, ...);
int eventfd(int /*<<< orphan*/, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ puts(char *);
int read(int, int /*<<< orphan*/ *, int);
int snprintf(char *, int, char *, ...);
scalar_t__ strlen(char *);
int write(int, char *, scalar_t__);
int main(int argc, char **argv) {
  int efd = -1;
  int cfd = -1;
  int event_control = -1;
  char event_control_path[PATH_MAX];
  char line[LINE_MAX];
  int ret;
  if (argc != 3)
    errx(1, "%s", "Usage: cgroup_event_listener <path-to-control-file> <args>");
  cfd = open(argv[1], O_RDONLY);
  if (cfd == -1)
    err(1, "Cannot open %s", argv[1]);
  ret = snprintf(event_control_path, PATH_MAX, "%s/cgroup.event_control",
                 dirname(argv[1]));
  if (ret >= PATH_MAX)
    errx(1, "Path to cgroup.event_control is too long");
  event_control = open(event_control_path, O_WRONLY);
  if (event_control == -1)
    err(1, "Cannot open %s", event_control_path);
  efd = eventfd(0, 0);
  if (efd == -1)
    err(1, "eventfd() failed");
  ret = snprintf(line, LINE_MAX, "%d %d %s", efd, cfd, argv[2]);
  if (ret >= LINE_MAX)
    errx(1, "Arguments string is too long");
  ret = write(event_control, line, strlen(line) + 1);
  if (ret == -1)
    err(1, "Cannot write to cgroup.event_control");
  while (1) {
    uint64_t result;
    ret = read(efd, &result, sizeof(result));
    if (ret == -1) {
      if (errno == EINTR)
        continue;
      err(1, "Cannot read from eventfd");
    }
    assert(ret == sizeof(result));
    ret = access(event_control_path, W_OK);
    if ((ret == -1) && (errno == ENOENT)) {
      puts("The cgroup seems to have removed.");
      break;
    }
    if (ret == -1)
      err(1, "cgroup.event_control is not accessible any more");
    printf("%s %s: crossed\n", argv[1], argv[2]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2daa(%rip),%rax
mov    (%rax),%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1270 <main+0xa0>
mov    $0x1,%edi
lea    0xe40(%rip),%rsi
lea    0xd97(%rip),%rdx
mov    $0x0,%al
call   1060 <errx@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2d61(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    12ae <main+0xde>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    $0x1,%edi
lea    0xd94(%rip),%rsi
mov    $0x0,%al
call   10c0 <err@plt>
mov    0x2d3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x54(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1090 <dirname@plt>
mov    -0x50(%rbp),%rdi
mov    -0x54(%rbp),%esi
mov    %rax,%rcx
lea    0xd72(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    0x2d04(%rip),%rcx
cmp    (%rcx),%eax
jl     1307 <main+0x137>
mov    $0x1,%edi
lea    0xd62(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    -0x50(%rbp),%rdi
mov    0x2c8e(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    133d <main+0x16d>
mov    -0x50(%rbp),%rdx
mov    $0x1,%edi
lea    0xd05(%rip),%rsi
mov    $0x0,%al
call   10c0 <err@plt>
xor    %esi,%esi
mov    %esi,%edi
call   10f0 <eventfd@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1366 <main+0x196>
mov    $0x1,%edi
lea    0xd2c(%rip),%rsi
mov    $0x0,%al
call   10c0 <err@plt>
mov    -0x48(%rbp),%rdi
mov    0x2c67(%rip),%rax
mov    (%rax),%esi
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r9
lea    0xd13(%rip),%rdx
mov    $0x0,%al
call   1080 <snprintf@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
mov    0x2c3b(%rip),%rcx
cmp    (%rcx),%eax
jl     13b8 <main+0x1e8>
mov    $0x1,%edi
lea    0xcf4(%rip),%rsi
mov    $0x0,%al
call   1060 <errx@plt>
mov    -0x48(%rbp),%rdi
mov    -0x1c(%rbp),%eax
mov    %eax,-0x58(%rbp)
call   1050 <strlen@plt>
mov    -0x58(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
call   1040 <write@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    13fa <main+0x22a>
mov    $0x1,%edi
lea    0xccf(%rip),%rsi
mov    $0x0,%al
call   10c0 <err@plt>
jmp    13ff <main+0x22f>
jmp    1404 <main+0x234>
mov    -0x14(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x4,%edx
call   10a0 <read@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    1454 <main+0x284>
mov    0x2b97(%rip),%rax
mov    (%rax),%rax
mov    0x2b85(%rip),%rcx
cmp    (%rcx),%rax
jne    1441 <main+0x271>
jmp    13ff <main+0x22f>
mov    $0x1,%edi
lea    0xc9a(%rip),%rsi
mov    $0x0,%al
call   10c0 <err@plt>
movslq -0x3c(%rbp),%rax
cmp    $0x4,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   10b0 <assert@plt>
mov    -0x50(%rbp),%rdi
mov    0x2b5c(%rip),%rax
mov    (%rax),%esi
call   10e0 <access@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0xffffffff,-0x3c(%rbp)
jne    14b3 <main+0x2e3>
mov    0x2b31(%rip),%rax
mov    (%rax),%rax
mov    0x2b0f(%rip),%rcx
cmp    (%rcx),%rax
jne    14b3 <main+0x2e3>
lea    0xc57(%rip),%rdi
call   1030 <puts@plt>
jmp    14f1 <main+0x321>
cmpl   $0xffffffff,-0x3c(%rbp)
jne    14d0 <main+0x300>
mov    $0x1,%edi
lea    0xc59(%rip),%rsi
mov    $0x0,%al
call   10c0 <err@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xc6b(%rip),%rdi
call   1070 <printf@plt>
jmp    13ff <main+0x22f>
movl   $0x0,-0x4(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r12
mov    0x2e05(%rip),%r13
mov    0x0(%r13),%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    0x2dcd(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
cmp    $0x3,%edi
je     123d <main+0x6d>
lea    0xe78(%rip),%rsi
lea    0xdcf(%rip),%rdx
mov    $0x1,%edi
xor    %eax,%eax
call   1060 <errx@plt>
mov    0x8(%r12),%rdi
mov    0x2d97(%rip),%rax
mov    (%rax),%esi
call   10d0 <open@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
jne    1270 <main+0xa0>
mov    0x8(%r12),%rdx
lea    0xdd7(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   10c0 <err@plt>
mov    0x0(%r13),%ebx
mov    0x8(%r12),%rdi
call   1090 <dirname@plt>
lea    0xdc5(%rip),%rdx
mov    -0x30(%rbp),%r14
mov    %r14,%rdi
mov    %ebx,%esi
mov    %rax,%rcx
xor    %eax,%eax
call   1080 <snprintf@plt>
cmp    0x0(%r13),%eax
jl     12b1 <main+0xe1>
lea    0xdbd(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1060 <errx@plt>
mov    0x2ce8(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   10d0 <open@plt>
mov    %eax,%r13d
cmp    $0xffffffff,%eax
jne    12e1 <main+0x111>
lea    0xd6a(%rip),%rsi
mov    $0x1,%edi
mov    -0x30(%rbp),%rdx
xor    %eax,%eax
call   10c0 <err@plt>
xor    %edi,%edi
xor    %esi,%esi
call   10f0 <eventfd@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1304 <main+0x134>
lea    0xd93(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   10c0 <err@plt>
mov    0x2ccd(%rip),%r14
mov    (%r14),%esi
mov    0x10(%r12),%r9
lea    0xd82(%rip),%rdx
mov    %r15,%rdi
mov    %ebx,%ecx
mov    -0x34(%rbp),%r8d
xor    %eax,%eax
call   1080 <snprintf@plt>
cmp    (%r14),%eax
jl     1342 <main+0x172>
lea    0xd6f(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   1060 <errx@plt>
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %r13d,%edi
mov    %r15,%rsi
call   1040 <write@plt>
cmp    $0xffffffff,%eax
jne    1371 <main+0x1a1>
lea    0xd5d(%rip),%rsi
mov    $0x1,%edi
xor    %eax,%eax
call   10c0 <err@plt>
lea    -0x38(%rbp),%r15
lea    0xdd6(%rip),%r13
jmp    13a5 <main+0x1d5>
xchg   %ax,%ax
mov    $0x1,%edi
lea    0xd96(%rip),%rsi
xor    %eax,%eax
call   10c0 <err@plt>
mov    0x8(%r12),%rsi
mov    0x10(%r12),%rdx
mov    %r13,%rdi
call   1070 <printf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    $0x4,%edx
call   10a0 <read@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    13e5 <main+0x215>
mov    0x2bfd(%rip),%rax
mov    (%rax),%rax
mov    0x2beb(%rip),%rcx
cmp    (%rcx),%rax
je     13a5 <main+0x1d5>
mov    $0x1,%edi
lea    0xd09(%rip),%rsi
xor    %eax,%eax
call   10c0 <err@plt>
xor    %edi,%edi
cmp    $0x4,%r14d
sete   %dil
call   10b0 <assert@plt>
mov    0x2bd5(%rip),%rax
mov    (%rax),%esi
mov    -0x30(%rbp),%rdi
call   10e0 <access@plt>
cmp    $0xffffffff,%eax
jne    1393 <main+0x1c3>
mov    0x2bae(%rip),%rax
mov    (%rax),%rax
mov    0x2b8c(%rip),%rcx
cmp    (%rcx),%rax
jne    1380 <main+0x1b0>
lea    0xcd4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@LINE_MAX = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [59 x i8] c"Usage: cgroup_event_listener <path-to-control-file> <args>\00"
@O_RDONLY = global i32 0
@.str.2 = [15 x i8] c"Cannot open %s\00"
@.str.3 = [24 x i8] c"%s/cgroup.event_control\00"
@.str.4 = [41 x i8] c"Path to cgroup.event_control is too long\00"
@O_WRONLY = global i32 0
@.str.5 = [17 x i8] c"eventfd() failed\00"
@.str.6 = [9 x i8] c"%d %d %s\00"
@.str.7 = [29 x i8] c"Arguments string is too long\00"
@.str.8 = [37 x i8] c"Cannot write to cgroup.event_control\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.9 = [25 x i8] c"Cannot read from eventfd\00"
@W_OK = global i32 0
@ENOENT = global i64 0
@.str.10 = [34 x i8] c"The cgroup seems to have removed.\00"
@.str.11 = [48 x i8] c"cgroup.event_control is not accessible any more\00"
@.str.12 = [16 x i8] c"%s %s: crossed\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 i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
store i32 -1, i32* %7
store i32 -1, i32* %8
%14 = load i32, i32* @PATH_MAX
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %9
%17 = alloca i8, i64 %15
store i64 %15, i64* %10
%18 = load i32, i32* @LINE_MAX
%19 = zext i32 %18 to i64
%20 = alloca i8, i64 %19
store i64 %19, i64* %11
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 3
br i1 %22, label %23, label %25
23: ; preds = %2
%24 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %23, %2
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = load i32, i32* @O_RDONLY
%30 = call i32 @open(i8* %28, i32 %29)
store i32 %30, i32* %7
%31 = load i32, i32* %7
%32 = icmp eq i32 %31, -1
br i1 %32, label %33, label %38
33: ; preds = %25
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %36)
br label %38
38: ; preds = %33, %25
%39 = load i32, i32* @PATH_MAX
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i8* @dirname(i8* %42)
%44 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %17, i32 %39, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %43)
store i32 %44, i32* %12
%45 = load i32, i32* %12
%46 = load i32, i32* @PATH_MAX
%47 = icmp sge i32 %45, %46
br i1 %47, label %48, label %50
48: ; preds = %38
%49 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
br label %50
50: ; preds = %48, %38
%51 = load i32, i32* @O_WRONLY
%52 = call i32 @open(i8* %17, i32 %51)
store i32 %52, i32* %8
%53 = load i32, i32* %8
%54 = icmp eq i32 %53, -1
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %17)
br label %57
57: ; preds = %55, %50
%58 = call i32 @eventfd(i32 0, i32 0)
store i32 %58, i32* %6
%59 = load i32, i32* %6
%60 = icmp eq i32 %59, -1
br i1 %60, label %61, label %63
61: ; preds = %57
%62 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %63
63: ; preds = %61, %57
%64 = load i32, i32* @LINE_MAX
%65 = load i32, i32* %6
%66 = load i32, i32* %7
%67 = load i8**, i8*** %5
%68 = getelementptr inbounds i8*, i8** %67, i64 2
%69 = load i8*, i8** %68
%70 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %20, i32 %64, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %65, i32 %66, i8* %69)
store i32 %70, i32* %12
%71 = load i32, i32* %12
%72 = load i32, i32* @LINE_MAX
%73 = icmp sge i32 %71, %72
br i1 %73, label %74, label %76
74: ; preds = %63
%75 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
br label %76
76: ; preds = %74, %63
%77 = load i32, i32* %8
%78 = call i64 @strlen(i8* %20)
%79 = add nsw i64 %78, 1
%80 = call i32 @write(i32 %77, i8* %20, i64 %79)
store i32 %80, i32* %12
%81 = load i32, i32* %12
%82 = icmp eq i32 %81, -1
br i1 %82, label %83, label %85
83: ; preds = %76
%84 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
br label %85
85: ; preds = %83, %76
br label %86
86: ; preds = %120, %96, %85
br label %87
87: ; preds = %86
%88 = load i32, i32* %6
%89 = call i32 @read(i32 %88, i32* %13, i32 4)
store i32 %89, i32* %12
%90 = load i32, i32* %12
%91 = icmp eq i32 %90, -1
br i1 %91, label %92, label %99
92: ; preds = %87
%93 = load i64, i64* @errno
%94 = load i64, i64* @EINTR
%95 = icmp eq i64 %93, %94
br i1 %95, label %96, label %97
96: ; preds = %92
br label %86
97: ; preds = %92
%98 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
br label %99
99: ; preds = %97, %87
%100 = load i32, i32* %12
%101 = sext i32 %100 to i64
%102 = icmp eq i64 %101, 4
%103 = zext i1 %102 to i32
%104 = call i32 @assert(i32 %103)
%105 = load i32, i32* @W_OK
%106 = call i32 @access(i8* %17, i32 %105)
store i32 %106, i32* %12
%107 = load i32, i32* %12
%108 = icmp eq i32 %107, -1
br i1 %108, label %109, label %115
109: ; preds = %99
%110 = load i64, i64* @errno
%111 = load i64, i64* @ENOENT
%112 = icmp eq i64 %110, %111
br i1 %112, label %113, label %115
113: ; preds = %109
%114 = call i32 @puts(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
br label %128
115: ; preds = %109, %99
%116 = load i32, i32* %12
%117 = icmp eq i32 %116, -1
br i1 %117, label %118, label %120
118: ; preds = %115
%119 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.11, i64 0, i64 0))
br label %120
120: ; preds = %118, %115
%121 = load i8**, i8*** %5
%122 = getelementptr inbounds i8*, i8** %121, i64 1
%123 = load i8*, i8** %122
%124 = load i8**, i8*** %5
%125 = getelementptr inbounds i8*, i8** %124, i64 2
%126 = load i8*, i8** %125
%127 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* %123, i8* %126)
br label %86
128: ; preds = %113
store i32 0, i32* %3
%129 = load i8*, i8** %9
%130 = load i32, i32* %3
ret i32 %130
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@LINE_MAX = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [59 x i8] c"Usage: cgroup_event_listener <path-to-control-file> <args>\00"
@O_RDONLY = global i32 0
@.str.2 = [15 x i8] c"Cannot open %s\00"
@.str.3 = [24 x i8] c"%s/cgroup.event_control\00"
@.str.4 = [41 x i8] c"Path to cgroup.event_control is too long\00"
@O_WRONLY = global i32 0
@.str.5 = [17 x i8] c"eventfd() failed\00"
@.str.6 = [9 x i8] c"%d %d %s\00"
@.str.7 = [29 x i8] c"Arguments string is too long\00"
@.str.8 = [37 x i8] c"Cannot write to cgroup.event_control\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.9 = [25 x i8] c"Cannot read from eventfd\00"
@W_OK = global i32 0
@ENOENT = global i64 0
@.str.10 = [34 x i8] c"The cgroup seems to have removed.\00"
@.str.11 = [48 x i8] c"cgroup.event_control is not accessible any more\00"
@.str.12 = [16 x i8] c"%s %s: crossed\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = load i32, i32* @PATH_MAX
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = load i32, i32* @LINE_MAX
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = icmp eq i32 %0, 3
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = tail call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.1, i64 0, i64 0))
br label %13
13: ; preds = %11, %2
%14 = getelementptr inbounds i8*, i8** %1, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_RDONLY
%17 = tail call i32 @open(i8* %15, i32 %16)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i8*, i8** %14
%21 = tail call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %19, %13
%23 = load i32, i32* @PATH_MAX
%24 = load i8*, i8** %14
%25 = tail call i8* @dirname(i8* %24)
%26 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %6, i32 %23, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @PATH_MAX
%28 = icmp slt i32 %26, %27
br i1 %28, label %31, label %29
29: ; preds = %22
%30 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %29, %22
%32 = load i32, i32* @O_WRONLY
%33 = call i32 @open(i8* %6, i32 %32)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %31
%36 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %6)
br label %37
37: ; preds = %35, %31
%38 = call i32 @eventfd(i32 0, i32 0)
%39 = icmp eq i32 %38, -1
br i1 %39, label %40, label %42
40: ; preds = %37
%41 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %40, %37
%43 = load i32, i32* @LINE_MAX
%44 = getelementptr inbounds i8*, i8** %1, i64 2
%45 = load i8*, i8** %44
%46 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 %43, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0), i32 %38, i32 %17, i8* %45)
%47 = load i32, i32* @LINE_MAX
%48 = icmp slt i32 %46, %47
br i1 %48, label %51, label %49
49: ; preds = %42
%50 = call i32 (i32, i8*, ...) @errx(i32 1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0))
br label %51
51: ; preds = %49, %42
%52 = call i64 @strlen(i8* %9)
%53 = add nsw i64 %52, 1
%54 = call i32 @write(i32 %33, i8* %9, i64 %53)
%55 = icmp eq i32 %54, -1
br i1 %55, label %56, label %58
56: ; preds = %51
%57 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.8, i64 0, i64 0))
br label %58
58: ; preds = %56, %51
%59 = bitcast i32* %3 to i8*
br label %60
60: ; preds = %86, %58
%61 = call i32 @read(i32 %38, i32* %3, i32 4)
%62 = icmp eq i32 %61, -1
br i1 %62, label %63, label %69
63: ; preds = %60
%64 = load i64, i64* @errno
%65 = load i64, i64* @EINTR
%66 = icmp eq i64 %64, %65
br i1 %66, label %86, label %67
67: ; preds = %63
%68 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.9, i64 0, i64 0))
br label %69
69: ; preds = %67, %60
%70 = icmp eq i32 %61, 4
%71 = zext i1 %70 to i32
%72 = call i32 @assert(i32 %71)
%73 = load i32, i32* @W_OK
%74 = call i32 @access(i8* %6, i32 %73)
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %82
76: ; preds = %69
%77 = load i64, i64* @errno
%78 = load i64, i64* @ENOENT
%79 = icmp eq i64 %77, %78
br i1 %79, label %87, label %80
80: ; preds = %76
%81 = call i32 (i32, i8*, ...) @err(i32 1, i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.11, i64 0, i64 0))
br label %82
82: ; preds = %69, %80
%83 = load i8*, i8** %14
%84 = load i8*, i8** %44
%85 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.12, i64 0, i64 0), i8* %83, i8* %84)
br label %86
86: ; preds = %63, %82
br label %60
87: ; preds = %76
%88 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.10, i64 0, i64 0))
ret i32 0
}