#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__ malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, int /*<<< orphan*/, int, int,
                            int);
int strlen(char *);
int mongo_mcon_supports_wire_version(int min_wire_version, int max_wire_version,
                                     char **error_message) {
  char *errmsg =
      "This driver version requires WireVersion between minWireVersion: %d and "
      "maxWireVersion: %d. Got: minWireVersion=%d and maxWireVersion=%d";
  int errlen = strlen(errmsg) - 8 + 1 + (4 * 10);
  if (min_wire_version > 2) {
    *error_message = (char *)malloc(errlen);
    snprintf(*error_message, errlen, errmsg, 0, 2, min_wire_version,
             max_wire_version);
    return 0;
  }
  if (max_wire_version < 0) {
    *error_message = (char *)malloc(errlen);
    snprintf(*error_message, errlen, errmsg, 0, 2, min_wire_version,
             max_wire_version);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<mongo_mcon_supports_wire_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
lea    0xeb7(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
sub    $0x8,%eax
add    $0x1,%eax
add    $0x28,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    11af <mongo_mcon_supports_wire_version+0x7f>
mov    -0x24(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%r9d
mov    -0xc(%rbp),%eax
xor    %ecx,%ecx
mov    $0x2,%r8d
mov    %eax,(%rsp)
call   1040 <snprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1203 <mongo_mcon_supports_wire_version+0xd3>
cmpl   $0x0,-0xc(%rbp)
jge    11fc <mongo_mcon_supports_wire_version+0xcc>
mov    -0x24(%rbp),%edi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
mov    -0x8(%rbp),%r9d
mov    -0xc(%rbp),%eax
xor    %ecx,%ecx
mov    $0x2,%r8d
mov    %eax,(%rsp)
call   1040 <snprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1203 <mongo_mcon_supports_wire_version+0xd3>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mongo_mcon_supports_wire_version>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r15
mov    %esi,%r12d
mov    %edi,%r14d
lea    0xeb4(%rip),%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
cmp    $0x2,%r14d
jg     1163 <mongo_mcon_supports_wire_version+0x33>
mov    $0x1,%ebp
test   %r12d,%r12d
jns    1192 <mongo_mcon_supports_wire_version+0x62>
add    $0x21,%ebx
mov    %ebx,%edi
call   1050 <malloc@plt>
mov    %rax,(%r15)
mov    %r12d,(%rsp)
lea    0xe85(%rip),%rdx
xor    %ebp,%ebp
mov    %rax,%rdi
mov    %ebx,%esi
xor    %ecx,%ecx
mov    $0x2,%r8d
mov    %r14d,%r9d
call   1040 <snprintf@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [137 x i8] c"This driver version requires WireVersion between minWireVersion: %d and maxWireVersion: %d. Got: minWireVersion=%d and maxWireVersion=%d\00"
define i32 @mongo_mcon_supports_wire_version(i32 %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i8*
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i8** %8
%10 = load i8*, i8** %8
%11 = call i32 @strlen(i8* %10)
%12 = sub nsw i32 %11, 8
%13 = add nsw i32 %12, 1
%14 = add nsw i32 %13, 40
store i32 %14, i32* %9
%15 = load i32, i32* %5
%16 = icmp sgt i32 %15, 2
br i1 %16, label %17, label %29
17: ; preds = %3
%18 = load i32, i32* %9
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
%21 = load i8**, i8*** %7
store i8* %20, i8** %21
%22 = load i8**, i8*** %7
%23 = load i8*, i8** %22
%24 = load i32, i32* %9
%25 = load i8*, i8** %8
%26 = load i32, i32* %5
%27 = load i32, i32* %6
%28 = call i32 @snprintf(i8* %23, i32 %24, i8* %25, i32 0, i32 2, i32 %26, i32 %27)
store i32 0, i32* %4
br label %45
29: ; preds = %3
%30 = load i32, i32* %6
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %44
32: ; preds = %29
%33 = load i32, i32* %9
%34 = call i64 @malloc(i32 %33)
%35 = inttoptr i64 %34 to i8*
%36 = load i8**, i8*** %7
store i8* %35, i8** %36
%37 = load i8**, i8*** %7
%38 = load i8*, i8** %37
%39 = load i32, i32* %9
%40 = load i8*, i8** %8
%41 = load i32, i32* %5
%42 = load i32, i32* %6
%43 = call i32 @snprintf(i8* %38, i32 %39, i8* %40, i32 0, i32 2, i32 %41, i32 %42)
store i32 0, i32* %4
br label %45
44: ; preds = %29
store i32 1, i32* %4
br label %45
45: ; preds = %44, %32, %17
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
@.str = [137 x i8] c"This driver version requires WireVersion between minWireVersion: %d and maxWireVersion: %d. Got: minWireVersion=%d and maxWireVersion=%d\00"
define i32 @mongo_mcon_supports_wire_version(i32 %0, i32 %1, i8** nocapture writeonly %2) {
%4 = tail call i32 @strlen(i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0))
%5 = add nsw i32 %4, 33
%6 = icmp sgt i32 %0, 2
%7 = icmp slt i32 %1, 0
%8 = or i1 %6, %7
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = tail call i64 @malloc(i32 %5)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %2
%12 = tail call i32 @snprintf(i8* %11, i32 %5, i8* getelementptr inbounds ([137 x i8], [137 x i8]* @.str, i64 0, i64 0), i32 0, i32 2, i32 %0, i32 %1)
br label %13
13: ; preds = %3, %9
%14 = phi i32 [ 0, %9 ], [ 1, %3 ]
ret i32 %14
}