#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 */

/* Variables and functions */
scalar_t__ cg_read_strstr(char const *, char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *);
int /*<<< orphan*/ stderr;
int cg_check_frozen(const char *cgroup, bool frozen) {
  if (frozen) {
    if (cg_read_strstr(cgroup, "cgroup.events", "frozen 1") != 0) {
      fprintf(stderr, "Cgroup %s isn't frozen\n", cgroup);
      return -1;
    }
  } else {
    if (cg_read_strstr(cgroup, "cgroup.events", "frozen 0") != 0) {
      fprintf(stderr, "Cgroup %s is frozen\n", cgroup);
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<cg_check_frozen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1184 <cg_check_frozen+0x64>
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
lea    0xec3(%rip),%rdx
call   1040 <cg_read_strstr@plt>
cmp    $0x0,%rax
je     117f <cg_check_frozen+0x5f>
mov    0x2e7f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xea9(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d6 <cg_check_frozen+0xb6>
jmp    11cf <cg_check_frozen+0xaf>
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
lea    0xe99(%rip),%rdx
call   1040 <cg_read_strstr@plt>
cmp    $0x0,%rax
je     11ca <cg_check_frozen+0xaa>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe7f(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11d6 <cg_check_frozen+0xb6>
jmp    11cf <cg_check_frozen+0xaf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cg_check_frozen>:
push   %rbx
mov    %rdi,%rbx
test   %esi,%esi
je     114c <cg_check_frozen+0x2c>
lea    0xed1(%rip),%rsi
lea    0xed8(%rip),%rdx
mov    %rbx,%rdi
call   1040 <cg_read_strstr@plt>
test   %rax,%rax
je     1186 <cg_check_frozen+0x66>
lea    0xecd(%rip),%rsi
jmp    116e <cg_check_frozen+0x4e>
lea    0xead(%rip),%rsi
lea    0xed5(%rip),%rdx
mov    %rbx,%rdi
call   1040 <cg_read_strstr@plt>
test   %rax,%rax
je     1186 <cg_check_frozen+0x66>
lea    0xeca(%rip),%rsi
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    %rbx,%rdx
call   1030 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"cgroup.events\00"
@.str.1 = [9 x i8] c"frozen 1\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"Cgroup %s isn't frozen\0A\00"
@.str.3 = [9 x i8] c"frozen 0\00"
@.str.4 = [21 x i8] c"Cgroup %s is frozen\0A\00"
define i32 @cg_check_frozen(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load i8*, i8** %4
%10 = call i64 @cg_read_strstr(i8* %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %4
%15 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i8* %14)
store i32 -1, i32* %3
br label %27
16: ; preds = %8
br label %26
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = call i64 @cg_read_strstr(i8* %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = load i8*, i8** %4
%24 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %23)
store i32 -1, i32* %3
br label %27
25: ; preds = %17
br label %26
26: ; preds = %25, %16
store i32 0, i32* %3
br label %27
27: ; preds = %26, %21, %12
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [14 x i8] c"cgroup.events\00"
@.str.1 = [9 x i8] c"frozen 1\00"
@stderr = global i32 0
@.str.2 = [24 x i8] c"Cgroup %s isn't frozen\0A\00"
@.str.3 = [9 x i8] c"frozen 0\00"
@.str.4 = [21 x i8] c"Cgroup %s is frozen\0A\00"
define i32 @cg_check_frozen(i8* %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br i1 %3, label %7, label %4
4: ; preds = %2
%5 = tail call i64 @cg_read_strstr(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %14, label %10
7: ; preds = %2
%8 = tail call i64 @cg_read_strstr(i8* %0, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7, %4
%11 = phi i8* [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), %4 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), %7 ]
%12 = load i32, i32* @stderr
%13 = tail call i32 @fprintf(i32 %12, i8* %11, i8* %0)
br label %14
14: ; preds = %10, %4, %7
%15 = phi i32 [ 0, %7 ], [ 0, %4 ], [ -1, %10 ]
ret i32 %15
}