#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int mnt_cnt(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int chk(char *fs_type, int cl_mnt, bool nag_mode) {
  if (nag_mode == true) {
    if (mnt_cnt(fs_type) == cl_mnt) {
      fprintf(stdout, "OK: %s Mounts: %d/%d\n", fs_type, mnt_cnt(fs_type),
              cl_mnt);
      exit(0);
    } else if (mnt_cnt(fs_type) > cl_mnt) {
      fprintf(stderr, "Err, I counted %d, you gave me %d\n", mnt_cnt(fs_type),
              cl_mnt);
      exit(3);
    } else {
      fprintf(stdout, "Critical: %s mounts: %d/%d found\n", fs_type,
              mnt_cnt(fs_type), cl_mnt);
      exit(2);
    }
  } else {
    fprintf(stdout, "%d/%d %s mounts found\n", mnt_cnt(fs_type), cl_mnt,
            fs_type);
  }
}


x86 assembly (clang, -O0):
<chk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    1226 <chk+0xf6>
mov    -0x10(%rbp),%rdi
call   1030 <mnt_cnt@plt>
cmp    -0x14(%rbp),%eax
jne    119d <chk+0x6d>
mov    0x2e73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <mnt_cnt@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
mov    -0x14(%rbp),%r8d
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <mnt_cnt@plt>
cmp    -0x14(%rbp),%eax
jle    11e4 <chk+0xb4>
mov    0x2e2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <mnt_cnt@plt>
mov    -0x28(%rbp),%edi
mov    %eax,%edx
mov    -0x14(%rbp),%ecx
lea    0xe43(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x3,%edi
call   1050 <exit@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <mnt_cnt@plt>
mov    -0x34(%rbp),%edi
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
mov    -0x14(%rbp),%r8d
lea    0xe24(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1050 <exit@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <mnt_cnt@plt>
mov    -0x38(%rbp),%edi
mov    %eax,%edx
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%r8
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<chk>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
cmp    $0x1,%edx
je     1175 <chk+0x45>
mov    0x2e8f(%rip),%rax
mov    (%rax),%ebp
mov    %rbx,%rdi
call   1030 <mnt_cnt@plt>
lea    0xf01(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
mov    %r15d,%ecx
mov    %rbx,%r8
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <mnt_cnt@plt>
cmp    %r15d,%eax
jne    11b4 <chk+0x84>
mov    0x2e4f(%rip),%rax
mov    (%rax),%r14d
mov    %rbx,%rdi
call   1030 <mnt_cnt@plt>
lea    0xe65(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
mov    %r15d,%r8d
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %edi,%edi
call   1050 <exit@plt>
mov    %rbx,%rdi
call   1030 <mnt_cnt@plt>
cmp    %r15d,%eax
jle    11f3 <chk+0xc3>
mov    0x2e18(%rip),%rax
mov    (%rax),%r14d
mov    %rbx,%rdi
call   1030 <mnt_cnt@plt>
lea    0xe3c(%rip),%rsi
mov    %r14d,%edi
mov    %eax,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x3,%edi
call   1050 <exit@plt>
mov    0x2dde(%rip),%rax
mov    (%rax),%r14d
mov    %rbx,%rdi
call   1030 <mnt_cnt@plt>
lea    0xe2d(%rip),%rsi
mov    %r14d,%edi
mov    %rbx,%rdx
mov    %eax,%ecx
mov    %r15d,%r8d
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [22 x i8] c"OK: %s Mounts: %d/%d\0A\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"Err, I counted %d, you gave me %d\0A\00"
@.str.2 = [34 x i8] c"Critical: %s mounts: %d/%d found\0A\00"
@.str.3 = [23 x i8] c"%d/%d %s mounts found\0A\00"
define i32 @chk(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %43
10: ; preds = %3
%11 = load i8*, i8** %5
%12 = call i32 @mnt_cnt(i8* %11)
%13 = load i32, i32* %6
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %23
15: ; preds = %10
%16 = load i32, i32* @stdout
%17 = load i8*, i8** %5
%18 = load i8*, i8** %5
%19 = call i32 @mnt_cnt(i8* %18)
%20 = load i32, i32* %6
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %17, i32 %19, i32 %20)
%22 = call i32 @exit(i32 0)
unreachable
23: ; preds = %10
%24 = load i8*, i8** %5
%25 = call i32 @mnt_cnt(i8* %24)
%26 = load i32, i32* %6
%27 = icmp sgt i32 %25, %26
br i1 %27, label %28, label %35
28: ; preds = %23
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %5
%31 = call i32 @mnt_cnt(i8* %30)
%32 = load i32, i32* %6
%33 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %31, i32 %32)
%34 = call i32 @exit(i32 3)
unreachable
35: ; preds = %23
%36 = load i32, i32* @stdout
%37 = load i8*, i8** %5
%38 = load i8*, i8** %5
%39 = call i32 @mnt_cnt(i8* %38)
%40 = load i32, i32* %6
%41 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %37, i32 %39, i32 %40)
%42 = call i32 @exit(i32 2)
unreachable
43: ; preds = %3
%44 = load i32, i32* @stdout
%45 = load i8*, i8** %5
%46 = call i32 @mnt_cnt(i8* %45)
%47 = load i32, i32* %6
%48 = load i8*, i8** %5
%49 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %46, i32 %47, i8* %48)
br label %50
50: ; preds = %43
%51 = load i32, i32* %4
ret i32 %51
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [22 x i8] c"OK: %s Mounts: %d/%d\0A\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"Err, I counted %d, you gave me %d\0A\00"
@.str.2 = [34 x i8] c"Critical: %s mounts: %d/%d found\0A\00"
@.str.3 = [23 x i8] c"%d/%d %s mounts found\0A\00"
define i32 @chk(i8* %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %2, 1
br i1 %4, label %5, label %26
5: ; preds = %3
%6 = tail call i32 @mnt_cnt(i8* %0)
%7 = icmp eq i32 %6, %1
br i1 %7, label %8, label %13
8: ; preds = %5
%9 = load i32, i32* @stdout
%10 = tail call i32 @mnt_cnt(i8* %0)
%11 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %10, i32 %1)
%12 = tail call i32 @exit(i32 0)
unreachable
13: ; preds = %5
%14 = tail call i32 @mnt_cnt(i8* %0)
%15 = icmp sgt i32 %14, %1
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = tail call i32 @mnt_cnt(i8* %0)
%19 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i32 %18, i32 %1)
%20 = tail call i32 @exit(i32 3)
unreachable
21: ; preds = %13
%22 = load i32, i32* @stdout
%23 = tail call i32 @mnt_cnt(i8* %0)
%24 = tail call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %0, i32 %23, i32 %1)
%25 = tail call i32 @exit(i32 2)
unreachable
26: ; preds = %3
%27 = load i32, i32* @stdout
%28 = tail call i32 @mnt_cnt(i8* %0)
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %1, i8* %0)
ret i32 undef
}