#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 RTAlerts_CurrentAlert_Has_Comments();
int /*<<< orphan*/ RTAlerts_Get_Current_Alert_Id();
int RTAlerts_Get_Number_of_Comments(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int);
const char *get_current_num_comments(void) {
  static char text[20];
  int has_comments = RTAlerts_CurrentAlert_Has_Comments();
  if (has_comments) {
    int num_comments =
        RTAlerts_Get_Number_of_Comments(RTAlerts_Get_Current_Alert_Id());
    sprintf(text, "%d", num_comments);
    return &text[0];
  } else
    return "";
}


x86 assembly (clang, -O0):
<get_current_num_comments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1050 <RTAlerts_CurrentAlert_Has_Comments@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1193 <get_current_num_comments+0x53>
mov    $0x0,%al
call   1040 <RTAlerts_Get_Current_Alert_Id@plt>
mov    %eax,%edi
call   1030 <RTAlerts_Get_Number_of_Comments@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%edx
lea    0x2ed9(%rip),%rdi
lea    0xe82(%rip),%rsi
call   1060 <sprintf@plt>
lea    0x2ec6(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119e <get_current_num_comments+0x5e>
lea    0xe68(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_current_num_comments>:
push   %rbx
xor    %eax,%eax
call   1050 <RTAlerts_CurrentAlert_Has_Comments@plt>
test   %eax,%eax
je     1174 <get_current_num_comments+0x34>
xor    %eax,%eax
call   1040 <RTAlerts_Get_Current_Alert_Id@plt>
mov    %eax,%edi
call   1030 <RTAlerts_Get_Number_of_Comments@plt>
lea    0x2eef(%rip),%rbx
lea    0xe98(%rip),%rsi
mov    %rbx,%rdi
mov    %eax,%edx
call   1060 <sprintf@plt>
jmp    117b <get_current_num_comments+0x3b>
lea    0xe87(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@get_current_num_comments.text = internal global [20 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @get_current_num_comments() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i32
%4 = call i32 (...) @RTAlerts_CurrentAlert_Has_Comments()
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %0
%8 = call i32 (...) @RTAlerts_Get_Current_Alert_Id()
%9 = call i32 @RTAlerts_Get_Number_of_Comments(i32 %8)
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = call i32 @sprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @get_current_num_comments.text, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %10)
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @get_current_num_comments.text, i64 0, i64 0), i8** %1
br label %13
12: ; preds = %0
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %1
br label %13
13: ; preds = %12, %7
%14 = load i8*, i8** %1
ret i8* %14
}

LLVM IR (-O2):
@get_current_num_comments.text = internal global [20 x i8] zeroinitializer
@.str = [3 x i8] c"%d\00"
@.str.1 = [1 x i8] zeroinitializer
define i8* @get_current_num_comments() {
%1 = tail call i32 (...) @RTAlerts_CurrentAlert_Has_Comments()
%2 = icmp eq i32 %1, 0
br i1 %2, label %7, label %3
3: ; preds = %0
%4 = tail call i32 (...) @RTAlerts_Get_Current_Alert_Id()
%5 = tail call i32 @RTAlerts_Get_Number_of_Comments(i32 %4)
%6 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @get_current_num_comments.text, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %0, %3
%8 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @get_current_num_comments.text, i64 0, i64 0), %3 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %0 ]
ret i8* %8
}