#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 */
typedef scalar_t__ uint8_t;

/* Variables and functions */
scalar_t__ asprintf(char **, char *, scalar_t__, scalar_t__, ...);
int /*<<< orphan*/ ie_mikrotik_version_separator(scalar_t__);
char *ie_mikrotik_version(uint8_t major, uint8_t minor, uint8_t type,
                          uint8_t rev) {
  char *version;
  if (rev) {
    if (asprintf(&version, "%d.%d%s%d", major, minor,
                 ie_mikrotik_version_separator(type), rev) < 0)
      version = NULL;
  } else {
    if (asprintf(&version, "%d.%d", major, minor) < 0)
      version = NULL;
  }
  return version;
}


x86 assembly (clang, -O0):
<ie_mikrotik_version>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1194 <ie_mikrotik_version+0x74>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <ie_mikrotik_version_separator@plt>
mov    -0x38(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    %eax,%r8d
mov    -0x20(%rbp),%r9
lea    -0x28(%rbp),%rdi
lea    0xe8a(%rip),%rsi
mov    $0x0,%al
call   1030 <asprintf@plt>
cmp    $0x0,%rax
jge    118f <ie_mikrotik_version+0x6f>
movq   $0x0,-0x28(%rbp)
jmp    11c5 <ie_mikrotik_version+0xa5>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    -0x28(%rbp),%rdi
lea    0xe63(%rip),%rsi
mov    $0x0,%al
call   1030 <asprintf@plt>
cmp    $0x0,%rax
jge    11c0 <ie_mikrotik_version+0xa0>
movq   $0x0,-0x28(%rbp)
jmp    11c5 <ie_mikrotik_version+0xa5>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ie_mikrotik_version>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
test   %rcx,%rcx
je     117b <ie_mikrotik_version+0x5b>
mov    %rcx,%rbx
mov    %rdx,%rdi
call   1040 <ie_mikrotik_version_separator@plt>
lea    0xeba(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %eax,%r8d
mov    %rbx,%r9
xor    %eax,%eax
call   1030 <asprintf@plt>
test   %rax,%rax
jns    116c <ie_mikrotik_version+0x4c>
movq   $0x0,0x8(%rsp)
mov    0x8(%rsp),%rax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe88(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    %r15,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   1030 <asprintf@plt>
test   %rax,%rax
jns    116c <ie_mikrotik_version+0x4c>
jmp    1163 <ie_mikrotik_version+0x43>

LLVM IR (-O0):
@.str = [10 x i8] c"%d.%d%s%d\00"
@.str.1 = [6 x i8] c"%d.%d\00"
define i8* @ie_mikrotik_version(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i64, i64* %8
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %22
12: ; preds = %4
%13 = load i64, i64* %5
%14 = load i64, i64* %6
%15 = load i64, i64* %7
%16 = call i32 @ie_mikrotik_version_separator(i64 %15)
%17 = load i64, i64* %8
%18 = call i64 (i8**, i8*, i64, i64, ...) @asprintf(i8** %9, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %13, i64 %14, i32 %16, i64 %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %12
store i8* null, i8** %9
br label %21
21: ; preds = %20, %12
br label %29
22: ; preds = %4
%23 = load i64, i64* %5
%24 = load i64, i64* %6
%25 = call i64 (i8**, i8*, i64, i64, ...) @asprintf(i8** %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %23, i64 %24)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %22
store i8* null, i8** %9
br label %28
28: ; preds = %27, %22
br label %29
29: ; preds = %28, %21
%30 = load i8*, i8** %9
ret i8* %30
}

LLVM IR (-O2):
@.str = [10 x i8] c"%d.%d%s%d\00"
@.str.1 = [6 x i8] c"%d.%d\00"
define i8* @ie_mikrotik_version(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = icmp eq i64 %3, 0
br i1 %7, label %13, label %8
8: ; preds = %4
%9 = tail call i32 @ie_mikrotik_version_separator(i64 %2)
%10 = call i64 (i8**, i8*, i64, i64, ...) @asprintf(i8** %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i64 %0, i64 %1, i32 %9, i64 %3)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %8
store i8* null, i8** %5
br label %17
13: ; preds = %4
%14 = call i64 (i8**, i8*, i64, i64, ...) @asprintf(i8** %5, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i64 %0, i64 %1)
%15 = icmp slt i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13
store i8* null, i8** %5
br label %17
17: ; preds = %13, %16, %8, %12
%18 = load i8*, i8** %5
ret i8* %18
}