#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int mdadm_version(char *);
int /*<<< orphan*/ mdmon_running(char *);
char *ping_monitor_version(char *);
int /*<<< orphan*/ stderr;
int check_mdmon_version(char *container) {
  char *version = NULL;
  if (!mdmon_running(container)) {
    ;
  } else {
    int ver;
    version = ping_monitor_version(container);
    ver = version ? mdadm_version(version) : -1;
    free(version);
    if (ver < 3002000) {
      fprintf(stderr,
              "mdmon: "
              "mdmon instance for %s cannot be disabled\n",
              container);
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_mdmon_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <mdmon_running@plt>
cmp    $0x0,%eax
jne    117b <check_mdmon_version+0x2b>
jmp    11f7 <check_mdmon_version+0xa7>
mov    -0x10(%rbp),%rdi
call   1030 <ping_monitor_version@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a4 <check_mdmon_version+0x54>
mov    -0x18(%rbp),%rdi
call   1050 <mdadm_version@plt>
mov    %eax,-0x20(%rbp)
jmp    11b1 <check_mdmon_version+0x61>
mov    $0xffffffff,%eax
mov    %eax,-0x20(%rbp)
jmp    11b1 <check_mdmon_version+0x61>
mov    -0x20(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x2dce90,-0x1c(%rbp)
jge    11f2 <check_mdmon_version+0xa2>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe1f(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11fe <check_mdmon_version+0xae>
jmp    11f7 <check_mdmon_version+0xa7>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_mdmon_version>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1070 <mdmon_running@plt>
xor    %r14d,%r14d
test   %eax,%eax
je     11b9 <check_mdmon_version+0x69>
mov    %rbx,%rdi
call   1030 <ping_monitor_version@plt>
test   %rax,%rax
je     1194 <check_mdmon_version+0x44>
mov    %rax,%rbp
mov    %rax,%rdi
call   1050 <mdadm_version@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1040 <free@plt>
cmp    $0x2dce90,%r15d
jl     119b <check_mdmon_version+0x4b>
jmp    11b9 <check_mdmon_version+0x69>
xor    %edi,%edi
call   1040 <free@plt>
mov    0x2e3e(%rip),%rax
mov    (%rax),%edi
lea    0xe55(%rip),%rsi
mov    %rbx,%rdx
call   1060 <fprintf@plt>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [49 x i8] c"mdmon: mdmon instance for %s cannot be disabled\0A\00"
define i32 @check_mdmon_version(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* null, i8** %4
%6 = load i8*, i8** %3
%7 = call i32 @mdmon_running(i8* %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %1
br label %30
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = call i8* @ping_monitor_version(i8* %11)
store i8* %12, i8** %4
%13 = load i8*, i8** %4
%14 = icmp ne i8* %13, null
br i1 %14, label %15, label %18
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i32 @mdadm_version(i8* %16)
br label %19
18: ; preds = %10
br label %19
19: ; preds = %18, %15
%20 = phi i32 [ %17, %15 ], [ -1, %18 ]
store i32 %20, i32* %5
%21 = load i8*, i8** %4
%22 = call i32 @free(i8* %21)
%23 = load i32, i32* %5
%24 = icmp slt i32 %23, 3002000
br i1 %24, label %25, label %29
25: ; preds = %19
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %3
%28 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %27)
store i32 -1, i32* %2
br label %31
29: ; preds = %19
br label %30
30: ; preds = %29, %9
store i32 0, i32* %2
br label %31
31: ; preds = %30, %25
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [49 x i8] c"mdmon: mdmon instance for %s cannot be disabled\0A\00"
define i32 @check_mdmon_version(i8* %0) {
%2 = tail call i32 @mdmon_running(i8* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = tail call i8* @ping_monitor_version(i8* %0)
%6 = icmp eq i8* %5, null
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @mdadm_version(i8* %5)
%9 = icmp slt i32 %8, 3002000
%10 = tail call i32 @free(i8* %5)
br i1 %9, label %13, label %16
11: ; preds = %4
%12 = tail call i32 @free(i8* null)
br label %13
13: ; preds = %11, %7
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %16
16: ; preds = %1, %7, %13
%17 = phi i32 [ -1, %13 ], [ 0, %7 ], [ 0, %1 ]
ret i32 %17
}