#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*/ free(char *);
int /*<<< orphan*/ gui_buffer_undo_snap(struct t_gui_buffer *);
int /*<<< orphan*/ gui_input_insert_string(struct t_gui_buffer *, char *, int);
int /*<<< orphan*/
gui_input_text_changed_modifier_and_signal(struct t_gui_buffer *, int, int);
char *string_convert_escaped_chars(char const *);
void gui_input_insert(struct t_gui_buffer *buffer, const char *args) {
  char *args2;
  if (args) {
    gui_buffer_undo_snap(buffer);
    args2 = string_convert_escaped_chars(args);
    gui_input_insert_string(buffer, (args2) ? args2 : args, -1);
    gui_input_text_changed_modifier_and_signal(buffer, 1, 1);
    if (args2)
      free(args2);
  }
}


x86 assembly (clang, -O0):
<gui_input_insert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e4 <gui_input_insert+0x94>
mov    -0x8(%rbp),%rdi
call   1040 <gui_buffer_undo_snap@plt>
mov    -0x10(%rbp),%rdi
call   1060 <string_convert_escaped_chars@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11a1 <gui_input_insert+0x51>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11a9 <gui_input_insert+0x59>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0xffffffff,%edx
call   1070 <gui_input_insert_string@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1050 <gui_input_text_changed_modifier_and_signal@plt>
cmpq   $0x0,-0x18(%rbp)
je     11df <gui_input_insert+0x8f>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
jmp    11e4 <gui_input_insert+0x94>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_input_insert>:
push   %r15
push   %r14
push   %rbx
test   %rsi,%rsi
je     11ab <gui_input_insert+0x5b>
mov    %rsi,%rbx
mov    %rdi,%r14
call   1040 <gui_buffer_undo_snap@plt>
mov    %rbx,%rdi
call   1060 <string_convert_escaped_chars@plt>
mov    %rax,%r15
test   %rax,%rax
cmovne %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0xffffffff,%edx
call   1070 <gui_input_insert_string@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
call   1050 <gui_input_text_changed_modifier_and_signal@plt>
test   %r15,%r15
je     11ab <gui_input_insert+0x5b>
mov    %r15,%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <free@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.t_gui_buffer = type { i32 }
define void @gui_input_insert(%struct.t_gui_buffer* %0, i8* %1) {
%3 = alloca %struct.t_gui_buffer*
%4 = alloca i8*
%5 = alloca i8*
store %struct.t_gui_buffer* %0, %struct.t_gui_buffer** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %31
8: ; preds = %2
%9 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %3
%10 = call i32 @gui_buffer_undo_snap(%struct.t_gui_buffer* %9)
%11 = load i8*, i8** %4
%12 = call i8* @string_convert_escaped_chars(i8* %11)
store i8* %12, i8** %5
%13 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %3
%14 = load i8*, i8** %5
%15 = icmp ne i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = load i8*, i8** %5
br label %20
18: ; preds = %8
%19 = load i8*, i8** %4
br label %20
20: ; preds = %18, %16
%21 = phi i8* [ %17, %16 ], [ %19, %18 ]
%22 = call i32 @gui_input_insert_string(%struct.t_gui_buffer* %13, i8* %21, i32 -1)
%23 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %3
%24 = call i32 @gui_input_text_changed_modifier_and_signal(%struct.t_gui_buffer* %23, i32 1, i32 1)
%25 = load i8*, i8** %5
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %30
27: ; preds = %20
%28 = load i8*, i8** %5
%29 = call i32 @free(i8* %28)
br label %30
30: ; preds = %27, %20
br label %31
31: ; preds = %30, %2
ret void
}

LLVM IR (-O2):
%struct.t_gui_buffer = type { i32 }
define void @gui_input_insert(%struct.t_gui_buffer* %0, i8* %1) {
%3 = icmp eq i8* %1, null
br i1 %3, label %13, label %4
4: ; preds = %2
%5 = tail call i32 @gui_buffer_undo_snap(%struct.t_gui_buffer* %0)
%6 = tail call i8* @string_convert_escaped_chars(i8* %1)
%7 = icmp eq i8* %6, null
%8 = select i1 %7, i8* %1, i8* %6
%9 = tail call i32 @gui_input_insert_string(%struct.t_gui_buffer* %0, i8* %8, i32 -1)
%10 = tail call i32 @gui_input_text_changed_modifier_and_signal(%struct.t_gui_buffer* %0, i32 1, i32 1)
br i1 %7, label %13, label %11
11: ; preds = %4
%12 = tail call i32 @free(i8* %6)
br label %13
13: ; preds = %4, %11, %2
ret void
}