#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*/ oom_control_path;
typedef int /*<<< orphan*/ line;
typedef int /*<<< orphan*/ event_control_path;

/* Variables and functions */
int LINE_MAX;
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ O_WRONLY;
int PATH_MAX;
int /*<<< orphan*/ PR_SET_PDEATHSIG;
int /*<<< orphan*/ SIGKILL;
int /*<<< orphan*/ assert(int);
int detect_oom(int, char *);
int eventfd(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int prctl(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/,
          int /*<<< orphan*/, int /*<<< orphan*/);
size_t snprintf(char *, int, char *, ...);
int /*<<< orphan*/ stderr;
int write(int, char *, size_t);
int main(int argc, char **argv) {
  int event_fd = -1;
  char oom_control_path[PATH_MAX];
  size_t oom_control_path_len;
  int oom_control_fd = -1;
  char event_control_path[PATH_MAX];
  size_t event_control_path_len;
  int event_control_fd = -1;
  char line[LINE_MAX];
  size_t line_len;
  int rv;
  if (argc != 2) {
    fprintf(stderr, "Usage: %s <path to cgroup>\n", argv[0]);
    return 1;
  }
  rv = prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
  if (rv == -1) {
    perror("prctl");
    return 1;
  }
  event_fd = eventfd(0, 0);
  if (event_fd == -1) {
    perror("eventfd");
    return 1;
  }
  oom_control_path_len = snprintf(oom_control_path, sizeof(oom_control_path),
                                  "%s/memory.oom_control", argv[1]);
  assert(oom_control_path_len < sizeof(oom_control_path));
  oom_control_fd = open(oom_control_path, O_RDONLY);
  if (oom_control_fd == -1) {
    perror("open");
    return 1;
  }
  event_control_path_len =
      snprintf(event_control_path, sizeof(event_control_path),
               "%s/cgroup.event_control", argv[1]);
  assert(event_control_path_len < sizeof(event_control_path));
  event_control_fd = open(event_control_path, O_WRONLY);
  if (event_control_fd == -1) {
    perror("open");
    return 1;
  }
  line_len = snprintf(line, sizeof(line), "%d %d\n", event_fd, oom_control_fd);
  assert(line_len < sizeof(line));
  rv = write(event_control_fd, line, line_len);
  if (rv == -1) {
    perror("write");
    return 1;
  }
  rv = detect_oom(event_fd, event_control_path);
  if (rv == -1) {
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    0x2e39(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0x98(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x90(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x28(%rbp)
movl   $0xffffffff,-0x34(%rbp)
mov    (%rax),%eax
mov    %rax,-0x88(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
movl   $0xffffffff,-0x4c(%rbp)
mov    0x2db8(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x78(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x70(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     127b <main+0xeb>
mov    0x2d6d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xd9d(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    14b3 <main+0x323>
mov    0x2d46(%rip),%rax
mov    (%rax),%edi
mov    0x2d2d(%rip),%rax
mov    (%rax),%esi
xor    %r8d,%r8d
mov    %r8d,%edx
mov    %r8d,%ecx
call   1080 <prctl@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    12c7 <main+0x137>
lea    0xd6d(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    14b3 <main+0x323>
xor    %esi,%esi
mov    %esi,%edi
call   10b0 <eventfd@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    12fc <main+0x16c>
lea    0xd3e(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    14b3 <main+0x323>
mov    -0x90(%rbp),%rdi
mov    -0x98(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd0f(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    %rax,%rcx
mov    -0x98(%rbp),%rax
mov    %rcx,-0x30(%rbp)
cmp    %rax,-0x30(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x90(%rbp),%rdi
mov    0x2c91(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1382 <main+0x1f2>
lea    0xcd6(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    14b3 <main+0x323>
mov    -0x80(%rbp),%rdi
mov    -0x88(%rbp),%rax
mov    %eax,%esi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xca7(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    %rax,%rcx
mov    -0x88(%rbp),%rax
mov    %rcx,-0x48(%rbp)
cmp    %rax,-0x48(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x80(%rbp),%rdi
mov    0x2bd9(%rip),%rax
mov    (%rax),%esi
call   1090 <open@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0xffffffff,-0x4c(%rbp)
jne    1402 <main+0x272>
lea    0xc56(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    14b3 <main+0x323>
mov    -0x70(%rbp),%rdi
mov    -0x78(%rbp),%rax
mov    %eax,%esi
mov    -0x14(%rbp),%ecx
mov    -0x34(%rbp),%r8d
lea    0xc43(%rip),%rdx
mov    $0x0,%al
call   1050 <snprintf@plt>
mov    %rax,%rcx
mov    -0x78(%rbp),%rax
mov    %rcx,-0x60(%rbp)
cmp    %rax,-0x60(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x70(%rbp),%rsi
mov    -0x4c(%rbp),%edi
mov    -0x60(%rbp),%rdx
call   1040 <write@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    1479 <main+0x2e9>
lea    0xc03(%rip),%rdi
call   10a0 <perror@plt>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    14b3 <main+0x323>
mov    -0x80(%rbp),%rsi
mov    -0x14(%rbp),%edi
call   1030 <detect_oom@plt>
mov    %eax,-0x64(%rbp)
cmpl   $0xffffffff,-0x64(%rbp)
jne    14a5 <main+0x315>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
jmp    14b3 <main+0x323>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x68(%rbp)
mov    -0x20(%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,%rbx
mov    0x2e45(%rip),%rax
mov    (%rax),%r13d
mov    %rsp,%r15
lea    0xf(%r13),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    0x2e09(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%r12
lea    0xf(%rcx),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
cmp    $0x2,%edi
jne    130a <main+0x17a>
mov    %rcx,-0x38(%rbp)
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    0x2db9(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1080 <prctl@plt>
cmp    $0xffffffff,%eax
je     132d <main+0x19d>
xor    %edi,%edi
xor    %esi,%esi
call   10b0 <eventfd@plt>
cmp    $0xffffffff,%eax
je     1336 <main+0x1a6>
mov    %eax,-0x30(%rbp)
mov    0x8(%rbx),%rcx
lea    0xdf4(%rip),%rdx
mov    %r15,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
xor    %edi,%edi
cmp    %r13,%rax
setb   %dil
call   1060 <assert@plt>
mov    0x2d88(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
call   1090 <open@plt>
cmp    $0xffffffff,%eax
je     1324 <main+0x194>
mov    %eax,%r15d
mov    0x8(%rbx),%rcx
lea    0xdcc(%rip),%rdx
mov    %r14,%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1050 <snprintf@plt>
xor    %edi,%edi
cmp    %r13,%rax
setb   %dil
call   1060 <assert@plt>
mov    0x2d0d(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1090 <open@plt>
cmp    $0xffffffff,%eax
je     1324 <main+0x194>
lea    0xdac(%rip),%rdx
mov    %r12,%rdi
mov    %r15d,%r8d
mov    -0x38(%rbp),%r15
mov    %r15d,%esi
mov    -0x30(%rbp),%r13d
mov    %r13d,%ecx
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
call   1050 <snprintf@plt>
mov    %rax,%rbx
xor    %edi,%edi
cmp    %r15,%rax
setb   %dil
call   1060 <assert@plt>
mov    -0x2c(%rbp),%edi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <write@plt>
cmp    $0xffffffff,%eax
je     133f <main+0x1af>
mov    %r13d,%edi
mov    %r14,%rsi
call   1030 <detect_oom@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
sete   %al
jmp    1350 <main+0x1c0>
mov    0x2caf(%rip),%rax
mov    (%rax),%edi
mov    (%rbx),%rdx
lea    0xce3(%rip),%rsi
call   1070 <fprintf@plt>
jmp    134b <main+0x1bb>
lea    0xd15(%rip),%rdi
jmp    1346 <main+0x1b6>
lea    0xce8(%rip),%rdi
jmp    1346 <main+0x1b6>
lea    0xce5(%rip),%rdi
jmp    1346 <main+0x1b6>
lea    0xd1e(%rip),%rdi
call   10a0 <perror@plt>
mov    $0x1,%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
@stderr = global i32 0
@.str = [28 x i8] c"Usage: %s <path to cgroup>\0A\00"
@PR_SET_PDEATHSIG = global i32 0
@SIGKILL = global i32 0
@.str.1 = [6 x i8] c"prctl\00"
@.str.2 = [8 x i8] c"eventfd\00"
@.str.3 = [22 x i8] c"%s/memory.oom_control\00"
@O_RDONLY = global i32 0
@.str.4 = [5 x i8] c"open\00"
@.str.5 = [24 x i8] c"%s/cgroup.event_control\00"
@O_WRONLY = global i32 0
@.str.6 = [7 x i8] c"%d %d\0A\00"
@.str.7 = [6 x i8] c"write\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i64
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i64
%15 = alloca i64
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %6
%18 = load i32, i32* @PATH_MAX
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %7
%21 = alloca i8, i64 %19
store i64 %19, i64* %8
store i32 -1, i32* %10
%22 = load i32, i32* @PATH_MAX
%23 = zext i32 %22 to i64
%24 = alloca i8, i64 %23
store i64 %23, i64* %11
store i32 -1, i32* %13
%25 = load i32, i32* @LINE_MAX
%26 = zext i32 %25 to i64
%27 = alloca i8, i64 %26
store i64 %26, i64* %14
%28 = load i32, i32* %4
%29 = icmp ne i32 %28, 2
br i1 %29, label %30, label %36
30: ; preds = %2
%31 = load i32, i32* @stderr
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 0
%34 = load i8*, i8** %33
%35 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %34)
store i32 1, i32* %3
store i32 1, i32* %17
br label %105
36: ; preds = %2
%37 = load i32, i32* @PR_SET_PDEATHSIG
%38 = load i32, i32* @SIGKILL
%39 = call i32 @prctl(i32 %37, i32 %38, i32 0, i32 0, i32 0)
store i32 %39, i32* %16
%40 = load i32, i32* %16
%41 = icmp eq i32 %40, -1
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %17
br label %105
44: ; preds = %36
%45 = call i32 @eventfd(i32 0, i32 0)
store i32 %45, i32* %6
%46 = load i32, i32* %6
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %44
%49 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %17
br label %105
50: ; preds = %44
%51 = trunc i64 %19 to i32
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %21, i32 %51, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %54)
store i64 %55, i64* %9
%56 = load i64, i64* %9
%57 = icmp ult i64 %56, %19
%58 = zext i1 %57 to i32
%59 = call i32 @assert(i32 %58)
%60 = load i32, i32* @O_RDONLY
%61 = call i32 @open(i8* %21, i32 %60)
store i32 %61, i32* %10
%62 = load i32, i32* %10
%63 = icmp eq i32 %62, -1
br i1 %63, label %64, label %66
64: ; preds = %50
%65 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %17
br label %105
66: ; preds = %50
%67 = trunc i64 %23 to i32
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 1
%70 = load i8*, i8** %69
%71 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %24, i32 %67, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %70)
store i64 %71, i64* %12
%72 = load i64, i64* %12
%73 = icmp ult i64 %72, %23
%74 = zext i1 %73 to i32
%75 = call i32 @assert(i32 %74)
%76 = load i32, i32* @O_WRONLY
%77 = call i32 @open(i8* %24, i32 %76)
store i32 %77, i32* %13
%78 = load i32, i32* %13
%79 = icmp eq i32 %78, -1
br i1 %79, label %80, label %82
80: ; preds = %66
%81 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %17
br label %105
82: ; preds = %66
%83 = trunc i64 %26 to i32
%84 = load i32, i32* %6
%85 = load i32, i32* %10
%86 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %27, i32 %83, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %84, i32 %85)
store i64 %86, i64* %15
%87 = load i64, i64* %15
%88 = icmp ult i64 %87, %26
%89 = zext i1 %88 to i32
%90 = call i32 @assert(i32 %89)
%91 = load i32, i32* %13
%92 = load i64, i64* %15
%93 = call i32 @write(i32 %91, i8* %27, i64 %92)
store i32 %93, i32* %16
%94 = load i32, i32* %16
%95 = icmp eq i32 %94, -1
br i1 %95, label %96, label %98
96: ; preds = %82
%97 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
store i32 1, i32* %17
br label %105
98: ; preds = %82
%99 = load i32, i32* %6
%100 = call i32 @detect_oom(i32 %99, i8* %24)
store i32 %100, i32* %16
%101 = load i32, i32* %16
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %104
103: ; preds = %98
store i32 1, i32* %3
store i32 1, i32* %17
br label %105
104: ; preds = %98
store i32 0, i32* %3
store i32 1, i32* %17
br label %105
105: ; preds = %104, %103, %96, %80, %64, %48, %42, %30
%106 = load i8*, i8** %7
%107 = load i32, i32* %3
ret i32 %107
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@LINE_MAX = global i32 0
@stderr = global i32 0
@.str = [28 x i8] c"Usage: %s <path to cgroup>\0A\00"
@PR_SET_PDEATHSIG = global i32 0
@SIGKILL = global i32 0
@.str.1 = [6 x i8] c"prctl\00"
@.str.2 = [8 x i8] c"eventfd\00"
@.str.3 = [22 x i8] c"%s/memory.oom_control\00"
@O_RDONLY = global i32 0
@.str.4 = [5 x i8] c"open\00"
@.str.5 = [24 x i8] c"%s/cgroup.event_control\00"
@O_WRONLY = global i32 0
@.str.6 = [7 x i8] c"%d %d\0A\00"
@.str.7 = [6 x i8] c"write\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i32, i32* @PATH_MAX
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = alloca i8, i64 %4
%7 = load i32, i32* @LINE_MAX
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = icmp eq i32 %0, 2
br i1 %10, label %15, label %11
11: ; preds = %2
%12 = load i32, i32* @stderr
%13 = load i8*, i8** %1
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %13)
br label %63
15: ; preds = %2
%16 = load i32, i32* @PR_SET_PDEATHSIG
%17 = load i32, i32* @SIGKILL
%18 = tail call i32 @prctl(i32 %16, i32 %17, i32 0, i32 0, i32 0)
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %63
22: ; preds = %15
%23 = tail call i32 @eventfd(i32 0, i32 0)
%24 = icmp eq i32 %23, -1
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %63
27: ; preds = %22
%28 = getelementptr inbounds i8*, i8** %1, i64 1
%29 = load i8*, i8** %28
%30 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %5, i32 %3, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = icmp ult i64 %30, %4
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = load i32, i32* @O_RDONLY
%35 = call i32 @open(i8* %5, i32 %34)
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %39
37: ; preds = %27
%38 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %63
39: ; preds = %27
%40 = load i8*, i8** %28
%41 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %6, i32 %3, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i8* %40)
%42 = icmp ult i64 %41, %4
%43 = zext i1 %42 to i32
%44 = call i32 @assert(i32 %43)
%45 = load i32, i32* @O_WRONLY
%46 = call i32 @open(i8* %6, i32 %45)
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %39
%49 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0))
br label %63
50: ; preds = %39
%51 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32 %23, i32 %35)
%52 = icmp ult i64 %51, %8
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
%55 = call i32 @write(i32 %46, i8* %9, i64 %51)
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %59
57: ; preds = %50
%58 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.7, i64 0, i64 0))
br label %63
59: ; preds = %50
%60 = call i32 @detect_oom(i32 %23, i8* %6)
%61 = icmp eq i32 %60, -1
%62 = zext i1 %61 to i32
br label %63
63: ; preds = %59, %57, %48, %37, %25, %20, %11
%64 = phi i32 [ 1, %11 ], [ 1, %20 ], [ 1, %25 ], [ 1, %37 ], [ 1, %48 ], [ 1, %57 ], [ %62, %59 ]
ret i32 %64
}