#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 gui_buffer_match_list_split(struct t_gui_buffer *, int, char **);
int /*<<< orphan*/ string_free_split(char **);
char **string_split(char const *, char *, int /*<<< orphan*/,
                    int /*<<< orphan*/, int *);
int gui_buffer_match_list(struct t_gui_buffer *buffer, const char *string) {
  char **buffers;
  int num_buffers, match;
  if (!string || !string[0])
    return 0;
  match = 0;
  buffers = string_split(string, ",", 0, 0, &num_buffers);
  if (buffers) {
    match = gui_buffer_match_list_split(buffer, num_buffers, buffers);
    string_free_split(buffers);
  }
  return match;
}


x86 assembly (clang, -O0):
<gui_buffer_match_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1158 <gui_buffer_match_list+0x28>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1164 <gui_buffer_match_list+0x34>
movl   $0x0,-0x4(%rbp)
jmp    11b4 <gui_buffer_match_list+0x84>
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe8a(%rip),%rsi
xor    %ecx,%ecx
lea    -0x24(%rbp),%r8
mov    %ecx,%edx
call   1050 <string_split@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11ae <gui_buffer_match_list+0x7e>
mov    -0x10(%rbp),%rdi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1040 <gui_buffer_match_list_split@plt>
mov    %eax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <string_free_split@plt>
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_buffer_match_list>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %ebx,%ebx
test   %rsi,%rsi
je     1186 <gui_buffer_match_list+0x56>
cmpb   $0x0,(%rsi)
je     1186 <gui_buffer_match_list+0x56>
mov    %rdi,%r14
lea    0xeb1(%rip),%rax
xor    %ebx,%ebx
lea    0xc(%rsp),%r8
mov    %rsi,%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1050 <string_split@plt>
test   %rax,%rax
je     1186 <gui_buffer_match_list+0x56>
mov    %rax,%r15
mov    0xc(%rsp),%esi
mov    %r14,%rdi
mov    %rax,%rdx
call   1040 <gui_buffer_match_list_split@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1030 <string_free_split@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.t_gui_buffer = type { i32 }
@.str = [2 x i8] c",\00"
define i32 @gui_buffer_match_list(%struct.t_gui_buffer* %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = icmp eq i8* %1, null
br i1 %5, label %16, label %6
6: ; preds = %2
%7 = load i8, i8* %1
%8 = icmp eq i8 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %6
%10 = call i8** @string_split(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32* %3)
%11 = icmp eq i8** %10, null
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = load i32, i32* %3
%14 = call i32 @gui_buffer_match_list_split(%struct.t_gui_buffer* %0, i32 %13, i8** %10)
%15 = call i32 @string_free_split(i8** %10)
br label %16
16: ; preds = %9, %12, %2, %6
%17 = phi i32 [ 0, %6 ], [ 0, %2 ], [ %14, %12 ], [ 0, %9 ]
ret i32 %17
}