#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 */
struct t_gui_buffer {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ gui_buffer_ask_chat_refresh(struct t_gui_buffer *, int);
int /*<<< orphan*/ gui_hotlist_remove_buffer(struct t_gui_buffer *,
                                             int /*<<< orphan*/);
int /*<<< orphan*/ gui_line_free_all(struct t_gui_buffer *);
int /*<<< orphan*/ hook_signal_send(char *, char *, struct t_gui_buffer *);
void gui_buffer_clear(struct t_gui_buffer *buffer) {
  if (!buffer)
    return;
  gui_line_free_all(buffer);
  gui_hotlist_remove_buffer(buffer, 0);
  gui_buffer_ask_chat_refresh(buffer, 2);
  (void)hook_signal_send("buffer_cleared", "pointer", buffer);
}


x86 assembly (clang, -O0):
<gui_buffer_clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    115c <gui_buffer_clear+0x1c>
jmp    1195 <gui_buffer_clear+0x55>
mov    -0x8(%rbp),%rdi
call   1030 <gui_line_free_all@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1060 <gui_hotlist_remove_buffer@plt>
mov    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1050 <gui_buffer_ask_chat_refresh@plt>
mov    -0x8(%rbp),%rdx
lea    0xe77(%rip),%rdi
lea    0xe7f(%rip),%rsi
call   1040 <hook_signal_send@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_buffer_clear>:
test   %rdi,%rdi
je     117c <gui_buffer_clear+0x3c>
push   %rbx
mov    %rdi,%rbx
call   1030 <gui_line_free_all@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <gui_hotlist_remove_buffer@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1050 <gui_buffer_ask_chat_refresh@plt>
lea    0xe94(%rip),%rdi
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdx
pop    %rbx
jmp    1040 <hook_signal_send@plt>
ret

LLVM IR (-O0):
%struct.t_gui_buffer = type { i32 }
@.str = [15 x i8] c"buffer_cleared\00"
@.str.1 = [8 x i8] c"pointer\00"
define void @gui_buffer_clear(%struct.t_gui_buffer* %0) {
%2 = alloca %struct.t_gui_buffer*
store %struct.t_gui_buffer* %0, %struct.t_gui_buffer** %2
%3 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %2
%4 = icmp ne %struct.t_gui_buffer* %3, null
br i1 %4, label %6, label %5
5: ; preds = %1
br label %15
6: ; preds = %1
%7 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %2
%8 = call i32 @gui_line_free_all(%struct.t_gui_buffer* %7)
%9 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %2
%10 = call i32 @gui_hotlist_remove_buffer(%struct.t_gui_buffer* %9, i32 0)
%11 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %2
%12 = call i32 @gui_buffer_ask_chat_refresh(%struct.t_gui_buffer* %11, i32 2)
%13 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %2
%14 = call i32 @hook_signal_send(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %struct.t_gui_buffer* %13)
br label %15
15: ; preds = %6, %5
ret void
}

LLVM IR (-O2):
%struct.t_gui_buffer = type { i32 }
@.str = [15 x i8] c"buffer_cleared\00"
@.str.1 = [8 x i8] c"pointer\00"
define void @gui_buffer_clear(%struct.t_gui_buffer* %0) {
%2 = icmp eq %struct.t_gui_buffer* %0, null
br i1 %2, label %8, label %3
3: ; preds = %1
%4 = tail call i32 @gui_line_free_all(%struct.t_gui_buffer* %0)
%5 = tail call i32 @gui_hotlist_remove_buffer(%struct.t_gui_buffer* %0, i32 0)
%6 = tail call i32 @gui_buffer_ask_chat_refresh(%struct.t_gui_buffer* %0, i32 2)
%7 = tail call i32 @hook_signal_send(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %struct.t_gui_buffer* %0)
br label %8
8: ; preds = %1, %3
ret void
}