#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 (!buffer || !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,-0x10(%rbp)
je     1163 <gui_buffer_match_list+0x33>
cmpq   $0x0,-0x18(%rbp)
je     1163 <gui_buffer_match_list+0x33>
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
jne    116f <gui_buffer_match_list+0x3f>
movl   $0x0,-0x4(%rbp)
jmp    11bf <gui_buffer_match_list+0x8f>
movl   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7f(%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     11b9 <gui_buffer_match_list+0x89>
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   %rdi,%rdi
je     118b <gui_buffer_match_list+0x5b>
test   %rsi,%rsi
je     118b <gui_buffer_match_list+0x5b>
cmpb   $0x0,(%rsi)
je     118b <gui_buffer_match_list+0x5b>
mov    %rdi,%r14
lea    0xeac(%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     118b <gui_buffer_match_list+0x5b>
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 %struct.t_gui_buffer*, %struct.t_gui_buffer** %4
%10 = icmp ne %struct.t_gui_buffer* %9, null
br i1 %10, label %11, label %19
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = icmp ne i8 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %14, %11, %2
store i32 0, i32* %3
br label %34
20: ; preds = %14
store i32 0, i32* %8
%21 = load i8*, i8** %5
%22 = call i8** @string_split(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 0, i32 0, i32* %7)
store i8** %22, i8*** %6
%23 = load i8**, i8*** %6
%24 = icmp ne i8** %23, null
br i1 %24, label %25, label %32
25: ; preds = %20
%26 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %4
%27 = load i32, i32* %7
%28 = load i8**, i8*** %6
%29 = call i32 @gui_buffer_match_list_split(%struct.t_gui_buffer* %26, i32 %27, i8** %28)
store i32 %29, i32* %8
%30 = load i8**, i8*** %6
%31 = call i32 @string_free_split(i8** %30)
br label %32
32: ; preds = %25, %20
%33 = load i32, i32* %8
store i32 %33, i32* %3
br label %34
34: ; preds = %32, %19
%35 = load i32, i32* %3
ret i32 %35
}

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 ne %struct.t_gui_buffer* %0, null
%6 = icmp ne i8* %1, null
%7 = and i1 %5, %6
br i1 %7, label %8, label %18
8: ; preds = %2
%9 = load i8, i8* %1
%10 = icmp eq i8 %9, 0
br i1 %10, label %18, label %11
11: ; preds = %8
%12 = 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)
%13 = icmp eq i8** %12, null
br i1 %13, label %18, label %14
14: ; preds = %11
%15 = load i32, i32* %3
%16 = call i32 @gui_buffer_match_list_split(%struct.t_gui_buffer* %0, i32 %15, i8** %12)
%17 = call i32 @string_free_split(i8** %12)
br label %18
18: ; preds = %11, %14, %2, %8
%19 = phi i32 [ 0, %8 ], [ 0, %2 ], [ %16, %14 ], [ 0, %11 ]
ret i32 %19
}