#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 int /*<<< orphan*/ model_name;

/* Variables and functions */
int lc15bts_model_get();
int lc15bts_rev_get();
size_t snprintf(char *, int, char *, ...);
const char *get_hwversion_desc() {
  int rev;
  int model;
  size_t len;
  static char model_name[64] = {
      0,
  };
  len = snprintf(model_name, sizeof(model_name), "NuRAN Litecell 1.5 BTS");
  rev = lc15bts_rev_get();
  if (rev >= 0) {
    len += snprintf(model_name + len, sizeof(model_name) - len, " Rev %c",
                    (char)rev);
  }
  model = lc15bts_model_get();
  if (model >= 0) {
    snprintf(model_name + len, sizeof(model_name) - len, "%s (%05X)",
             model_name, model);
  }
  return model_name;
}


x86 assembly (clang, -O0):
<get_hwversion_desc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0x2f11(%rip),%rdi
mov    $0x40,%esi
lea    0xeb5(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <lc15bts_rev_get@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     119c <get_hwversion_desc+0x6c>
lea    0x2edf(%rip),%rdi
add    -0x10(%rbp),%rdi
mov    $0x40,%eax
sub    -0x10(%rbp),%rax
mov    %eax,%esi
mov    -0x4(%rbp),%eax
movsbl %al,%ecx
lea    0xe8a(%rip),%rdx
mov    $0x0,%al
call   1040 <snprintf@plt>
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <lc15bts_model_get@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     11df <get_hwversion_desc+0xaf>
lea    0x2e99(%rip),%rdi
add    -0x10(%rbp),%rdi
mov    $0x40,%eax
sub    -0x10(%rbp),%rax
mov    %eax,%esi
mov    -0x8(%rbp),%r8d
lea    0xe4e(%rip),%rdx
lea    0x2e78(%rip),%rcx
mov    $0x0,%al
call   1040 <snprintf@plt>
lea    0x2e6a(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_hwversion_desc>:
push   %rbp
push   %r14
push   %rbx
lea    0x2f15(%rip),%r14
lea    0xebe(%rip),%rdx
mov    $0x40,%ebp
mov    %r14,%rdi
mov    $0x40,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <lc15bts_rev_get@plt>
test   %eax,%eax
js     1180 <get_hwversion_desc+0x50>
lea    (%r14,%rbx,1),%rdi
sub    %ebx,%ebp
movsbl %al,%ecx
lea    0xea3(%rip),%rdx
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <snprintf@plt>
add    %rax,%rbx
xor    %eax,%eax
call   1030 <lc15bts_model_get@plt>
test   %eax,%eax
js     11aa <get_hwversion_desc+0x7a>
lea    (%r14,%rbx,1),%rdi
mov    $0x40,%esi
sub    %ebx,%esi
lea    0xe82(%rip),%rdx
mov    %r14,%rcx
mov    %eax,%r8d
xor    %eax,%eax
call   1040 <snprintf@plt>
lea    0x2e9f(%rip),%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@get_hwversion_desc.model_name = internal global [64 x i8] zeroinitializer
@.str = [23 x i8] c"NuRAN Litecell 1.5 BTS\00"
@.str.1 = [8 x i8] c" Rev %c\00"
@.str.2 = [10 x i8] c"%s (%05X)\00"
define i8* @get_hwversion_desc() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i64
%4 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_hwversion_desc.model_name, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i64 %4, i64* %3
%5 = call i32 (...) @lc15bts_rev_get()
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = icmp sge i32 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %0
%9 = load i64, i64* %3
%10 = getelementptr inbounds i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_hwversion_desc.model_name, i64 0, i64 0), i64 %9
%11 = load i64, i64* %3
%12 = sub i64 64, %11
%13 = trunc i64 %12 to i32
%14 = load i32, i32* %1
%15 = trunc i32 %14 to i8
%16 = sext i8 %15 to i32
%17 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %10, i32 %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i64, i64* %3
%19 = add i64 %18, %17
store i64 %19, i64* %3
br label %20
20: ; preds = %8, %0
%21 = call i32 (...) @lc15bts_model_get()
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = icmp sge i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %20
%25 = load i64, i64* %3
%26 = getelementptr inbounds i8, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_hwversion_desc.model_name, i64 0, i64 0), i64 %25
%27 = load i64, i64* %3
%28 = sub i64 64, %27
%29 = trunc i64 %28 to i32
%30 = load i32, i32* %2
%31 = call i64 (i8*, i32, i8*, ...) @snprintf(i8* %26, i32 %29, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_hwversion_desc.model_name, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %24, %20
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_hwversion_desc.model_name, i64 0, i64 0)
}

LLVM IR (-O2):
@get_hwversion_desc.model_name = internal global [64 x i8] zeroinitializer
@.str = [23 x i8] c"NuRAN Litecell 1.5 BTS\00"
@.str.1 = [8 x i8] c" Rev %c\00"
@.str.2 = [10 x i8] c"%s (%05X)\00"
define i8* @get_hwversion_desc() {
%1 = tail call i64 (i8*, i32, i8*, ...) @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_hwversion_desc.model_name, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 (...) @lc15bts_rev_get()
%3 = icmp sgt i32 %2, -1
br i1 %3, label %4, label %12
4: ; preds = %0
%5 = getelementptr inbounds [64 x i8], [64 x i8]* @get_hwversion_desc.model_name, i64 0, i64 %1
%6 = trunc i64 %1 to i32
%7 = sub i32 64, %6
%8 = shl i32 %2, 24
%9 = ashr exact i32 %8, 24
%10 = tail call i64 (i8*, i32, i8*, ...) @snprintf(i8* %5, i32 %7, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = add i64 %10, %1
br label %12
12: ; preds = %4, %0
%13 = phi i64 [ %11, %4 ], [ %1, %0 ]
%14 = tail call i32 (...) @lc15bts_model_get()
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = getelementptr inbounds [64 x i8], [64 x i8]* @get_hwversion_desc.model_name, i64 0, i64 %13
%18 = trunc i64 %13 to i32
%19 = sub i32 64, %18
%20 = tail call i64 (i8*, i32, i8*, ...) @snprintf(i8* %17, i32 %19, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_hwversion_desc.model_name, i64 0, i64 0), i32 %14)
br label %21
21: ; preds = %16, %12
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @get_hwversion_desc.model_name, i64 0, i64 0)
}