#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 devname2devnum(char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
int mdadm_version(char *);
int /*<<< orphan*/ mdmon_running(int);
char *ping_monitor_version(char *);
int /*<<< orphan*/ stderr;
int check_mdmon_version(char *container) {
  char *version = NULL;
  int devnum = devname2devnum(container);
  if (!mdmon_running(devnum)) {
    ;
  } else {
    int ver;
    version = ping_monitor_version(container);
    ver = version ? mdadm_version(version) : -1;
    free(version);
    if (ver < 3002000) {
      fprintf(stderr,
              "mdadm"
              ": 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    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <devname2devnum@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1080 <mdmon_running@plt>
cmp    $0x0,%eax
jne    1196 <check_mdmon_version+0x36>
jmp    1212 <check_mdmon_version+0xb2>
mov    -0x10(%rbp),%rdi
call   1030 <ping_monitor_version@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11bf <check_mdmon_version+0x5f>
mov    -0x18(%rbp),%rdi
call   1060 <mdadm_version@plt>
mov    %eax,-0x24(%rbp)
jmp    11cc <check_mdmon_version+0x6c>
mov    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
jmp    11cc <check_mdmon_version+0x6c>
mov    -0x24(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
cmpl   $0x2dce90,-0x20(%rbp)
jge    120d <check_mdmon_version+0xad>
mov    0x2df1(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe04(%rip),%rsi
call   1070 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1219 <check_mdmon_version+0xb9>
jmp    1212 <check_mdmon_version+0xb2>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_mdmon_version>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <devname2devnum@plt>
mov    %eax,%edi
call   1080 <mdmon_running@plt>
xor    %ebp,%ebp
test   %eax,%eax
je     11ce <check_mdmon_version+0x6e>
mov    %r14,%rdi
call   1030 <ping_monitor_version@plt>
test   %rax,%rax
je     11aa <check_mdmon_version+0x4a>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <mdadm_version@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1040 <free@plt>
cmp    $0x2dce90,%r15d
jl     11b1 <check_mdmon_version+0x51>
jmp    11ce <check_mdmon_version+0x6e>
xor    %edi,%edi
call   1040 <free@plt>
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
mov    %r14,%rdx
call   1070 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%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"mdadm: 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
%6 = alloca i32
store i8* %0, i8** %3
store i8* null, i8** %4
%7 = load i8*, i8** %3
%8 = call i32 @devname2devnum(i8* %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = call i32 @mdmon_running(i32 %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %1
br label %33
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i8* @ping_monitor_version(i8* %14)
store i8* %15, i8** %4
%16 = load i8*, i8** %4
%17 = icmp ne i8* %16, null
br i1 %17, label %18, label %21
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = call i32 @mdadm_version(i8* %19)
br label %22
21: ; preds = %13
br label %22
22: ; preds = %21, %18
%23 = phi i32 [ %20, %18 ], [ -1, %21 ]
store i32 %23, i32* %6
%24 = load i8*, i8** %4
%25 = call i32 @free(i8* %24)
%26 = load i32, i32* %6
%27 = icmp slt i32 %26, 3002000
br i1 %27, label %28, label %32
28: ; preds = %22
%29 = load i32, i32* @stderr
%30 = load i8*, i8** %3
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8* %30)
store i32 -1, i32* %2
br label %34
32: ; preds = %22
br label %33
33: ; preds = %32, %12
store i32 0, i32* %2
br label %34
34: ; preds = %33, %28
%35 = load i32, i32* %2
ret i32 %35
}

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