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

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ gui_buffer_set_highlight_words(struct t_gui_buffer *,
                                                  char *);
char *malloc(int);
int /*<<< orphan*/ strcat(char *, char const *);
scalar_t__ strlen(char const *);
struct t_weelist_item *weelist_get(struct t_weelist *, int /*<<< orphan*/);
struct t_weelist_item *weelist_next(struct t_weelist_item *);
char *weelist_string(struct t_weelist_item *);
void gui_buffer_set_highlight_words_list(struct t_gui_buffer *buffer,
                                         struct t_weelist *list) {
  struct t_weelist_item *ptr_list_item;
  int length;
  const char *ptr_string;
  char *words;
  length = 0;
  for (ptr_list_item = weelist_get(list, 0); ptr_list_item;
       ptr_list_item = weelist_next(ptr_list_item)) {
    ptr_string = weelist_string(ptr_list_item);
    if (ptr_string)
      length += strlen(ptr_string) + 1;
  }
  length += 2;
  words = malloc(length);
  if (!words)
    return;
  words[0] = '\0';
  for (ptr_list_item = weelist_get(list, 0); ptr_list_item;
       ptr_list_item = weelist_next(ptr_list_item)) {
    ptr_string = weelist_string(ptr_list_item);
    if (ptr_string) {
      strcat(words, ptr_string);
      if (weelist_next(ptr_list_item))
        strcat(words, ",");
    }
  }
  gui_buffer_set_highlight_words(buffer, words);
  free(words);
}


x86 assembly (clang, -O0):
<gui_buffer_set_highlight_words_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1060 <weelist_get@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     11fa <gui_buffer_set_highlight_words_list+0x7a>
mov    -0x18(%rbp),%rdi
call   1040 <weelist_string@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11e3 <gui_buffer_set_highlight_words_list+0x63>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
add    $0x1,%rcx
movslq -0x1c(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x1c(%rbp)
jmp    11e8 <gui_buffer_set_highlight_words_list+0x68>
mov    -0x18(%rbp),%rdi
call   10a0 <weelist_next@plt>
mov    %rax,-0x18(%rbp)
jmp    11a6 <gui_buffer_set_highlight_words_list+0x26>
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1070 <malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    121f <gui_buffer_set_highlight_words_list+0x9f>
jmp    12ba <gui_buffer_set_highlight_words_list+0x13a>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1060 <weelist_get@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     12a4 <gui_buffer_set_highlight_words_list+0x124>
mov    -0x18(%rbp),%rdi
call   1040 <weelist_string@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     128d <gui_buffer_set_highlight_words_list+0x10d>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   10a0 <weelist_next@plt>
cmp    $0x0,%rax
je     1288 <gui_buffer_set_highlight_words_list+0x108>
mov    -0x30(%rbp),%rdi
lea    0xd7d(%rip),%rsi
call   1090 <strcat@plt>
jmp    128d <gui_buffer_set_highlight_words_list+0x10d>
jmp    1292 <gui_buffer_set_highlight_words_list+0x112>
mov    -0x18(%rbp),%rdi
call   10a0 <weelist_next@plt>
mov    %rax,-0x18(%rbp)
jmp    1235 <gui_buffer_set_highlight_words_list+0xb5>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1080 <gui_buffer_set_highlight_words@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gui_buffer_set_highlight_words_list>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
xor    %r12d,%r12d
mov    %rsi,%rdi
xor    %esi,%esi
call   1060 <weelist_get@plt>
test   %rax,%rax
je     11de <gui_buffer_set_highlight_words_list+0x5e>
mov    %rax,%rbx
xor    %r12d,%r12d
jmp    11c0 <gui_buffer_set_highlight_words_list+0x40>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   10a0 <weelist_next@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11de <gui_buffer_set_highlight_words_list+0x5e>
mov    %rbx,%rdi
call   1040 <weelist_string@plt>
test   %rax,%rax
je     11b0 <gui_buffer_set_highlight_words_list+0x30>
mov    %rax,%rdi
call   1050 <strlen@plt>
add    %eax,%r12d
add    $0x1,%r12d
jmp    11b0 <gui_buffer_set_highlight_words_list+0x30>
add    $0x2,%r12d
mov    %r12d,%edi
call   1070 <malloc@plt>
test   %rax,%rax
je     1280 <gui_buffer_set_highlight_words_list+0x100>
mov    %rax,%r12
movb   $0x0,(%rax)
mov    %r15,%rdi
xor    %esi,%esi
call   1060 <weelist_get@plt>
test   %rax,%rax
je     1262 <gui_buffer_set_highlight_words_list+0xe2>
mov    %rax,%rbx
lea    0xdee(%rip),%r15
jmp    1230 <gui_buffer_set_highlight_words_list+0xb0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbx,%rdi
call   10a0 <weelist_next@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1262 <gui_buffer_set_highlight_words_list+0xe2>
mov    %rbx,%rdi
call   1040 <weelist_string@plt>
test   %rax,%rax
je     1220 <gui_buffer_set_highlight_words_list+0xa0>
mov    %r12,%rdi
mov    %rax,%rsi
call   1090 <strcat@plt>
mov    %rbx,%rdi
call   10a0 <weelist_next@plt>
test   %rax,%rax
je     1220 <gui_buffer_set_highlight_words_list+0xa0>
mov    %r12,%rdi
mov    %r15,%rsi
call   1090 <strcat@plt>
jmp    1220 <gui_buffer_set_highlight_words_list+0xa0>
mov    %r14,%rdi
mov    %r12,%rsi
call   1080 <gui_buffer_set_highlight_words@plt>
mov    %r12,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.t_gui_buffer = type { i32 }
%struct.t_weelist = type { i32 }
%struct.t_weelist_item = type { i32 }
@.str = [2 x i8] c",\00"
define void @gui_buffer_set_highlight_words_list(%struct.t_gui_buffer* %0, %struct.t_weelist* %1) {
%3 = alloca %struct.t_gui_buffer*
%4 = alloca %struct.t_weelist*
%5 = alloca %struct.t_weelist_item*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
store %struct.t_gui_buffer* %0, %struct.t_gui_buffer** %3
store %struct.t_weelist* %1, %struct.t_weelist** %4
store i32 0, i32* %6
%9 = load %struct.t_weelist*, %struct.t_weelist** %4
%10 = call %struct.t_weelist_item* @weelist_get(%struct.t_weelist* %9, i32 0)
store %struct.t_weelist_item* %10, %struct.t_weelist_item** %5
br label %11
11: ; preds = %28, %2
%12 = load %struct.t_weelist_item*, %struct.t_weelist_item** %5
%13 = icmp ne %struct.t_weelist_item* %12, null
br i1 %13, label %14, label %31
14: ; preds = %11
%15 = load %struct.t_weelist_item*, %struct.t_weelist_item** %5
%16 = call i8* @weelist_string(%struct.t_weelist_item* %15)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %27
19: ; preds = %14
%20 = load i8*, i8** %7
%21 = call i64 @strlen(i8* %20)
%22 = add nsw i64 %21, 1
%23 = load i32, i32* %6
%24 = sext i32 %23 to i64
%25 = add nsw i64 %24, %22
%26 = trunc i64 %25 to i32
store i32 %26, i32* %6
br label %27
27: ; preds = %19, %14
br label %28
28: ; preds = %27
%29 = load %struct.t_weelist_item*, %struct.t_weelist_item** %5
%30 = call %struct.t_weelist_item* @weelist_next(%struct.t_weelist_item* %29)
store %struct.t_weelist_item* %30, %struct.t_weelist_item** %5
br label %11
31: ; preds = %11
%32 = load i32, i32* %6
%33 = add nsw i32 %32, 2
store i32 %33, i32* %6
%34 = load i32, i32* %6
%35 = call i8* @malloc(i32 %34)
store i8* %35, i8** %8
%36 = load i8*, i8** %8
%37 = icmp ne i8* %36, null
br i1 %37, label %39, label %38
38: ; preds = %31
br label %73
39: ; preds = %31
%40 = load i8*, i8** %8
%41 = getelementptr inbounds i8, i8* %40, i64 0
store i8 0, i8* %41
%42 = load %struct.t_weelist*, %struct.t_weelist** %4
%43 = call %struct.t_weelist_item* @weelist_get(%struct.t_weelist* %42, i32 0)
store %struct.t_weelist_item* %43, %struct.t_weelist_item** %5
br label %44
44: ; preds = %64, %39
%45 = load %struct.t_weelist_item*, %struct.t_weelist_item** %5
%46 = icmp ne %struct.t_weelist_item* %45, null
br i1 %46, label %47, label %67
47: ; preds = %44
%48 = load %struct.t_weelist_item*, %struct.t_weelist_item** %5
%49 = call i8* @weelist_string(%struct.t_weelist_item* %48)
store i8* %49, i8** %7
%50 = load i8*, i8** %7
%51 = icmp ne i8* %50, null
br i1 %51, label %52, label %63
52: ; preds = %47
%53 = load i8*, i8** %8
%54 = load i8*, i8** %7
%55 = call i32 @strcat(i8* %53, i8* %54)
%56 = load %struct.t_weelist_item*, %struct.t_weelist_item** %5
%57 = call %struct.t_weelist_item* @weelist_next(%struct.t_weelist_item* %56)
%58 = icmp ne %struct.t_weelist_item* %57, null
br i1 %58, label %59, label %62
59: ; preds = %52
%60 = load i8*, i8** %8
%61 = call i32 @strcat(i8* %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %62
62: ; preds = %59, %52
br label %63
63: ; preds = %62, %47
br label %64
64: ; preds = %63
%65 = load %struct.t_weelist_item*, %struct.t_weelist_item** %5
%66 = call %struct.t_weelist_item* @weelist_next(%struct.t_weelist_item* %65)
store %struct.t_weelist_item* %66, %struct.t_weelist_item** %5
br label %44
67: ; preds = %44
%68 = load %struct.t_gui_buffer*, %struct.t_gui_buffer** %3
%69 = load i8*, i8** %8
%70 = call i32 @gui_buffer_set_highlight_words(%struct.t_gui_buffer* %68, i8* %69)
%71 = load i8*, i8** %8
%72 = call i32 @free(i8* %71)
br label %73
73: ; preds = %67, %38
ret void
}

LLVM IR (-O2):
%struct.t_gui_buffer = type { i32 }
%struct.t_weelist = type { i32 }
%struct.t_weelist_item = type { i32 }
@.str = [2 x i8] c",\00"
define void @gui_buffer_set_highlight_words_list(%struct.t_gui_buffer* %0, %struct.t_weelist* %1) {
%3 = tail call %struct.t_weelist_item* @weelist_get(%struct.t_weelist* %1, i32 0)
%4 = icmp eq %struct.t_weelist_item* %3, null
br i1 %4, label %19, label %5
5: ; preds = %2, %15
%6 = phi %struct.t_weelist_item* [ %17, %15 ], [ %3, %2 ]
%7 = phi i32 [ %16, %15 ], [ 0, %2 ]
%8 = tail call i8* @weelist_string(%struct.t_weelist_item* %6)
%9 = icmp eq i8* %8, null
br i1 %9, label %15, label %10
10: ; preds = %5
%11 = tail call i64 @strlen(i8* %8)
%12 = trunc i64 %11 to i32
%13 = add i32 %7, 1
%14 = add i32 %13, %12
br label %15
15: ; preds = %5, %10
%16 = phi i32 [ %14, %10 ], [ %7, %5 ]
%17 = tail call %struct.t_weelist_item* @weelist_next(%struct.t_weelist_item* %6)
%18 = icmp eq %struct.t_weelist_item* %17, null
br i1 %18, label %19, label %5
19: ; preds = %15, %2
%20 = phi i32 [ 0, %2 ], [ %16, %15 ]
%21 = add nsw i32 %20, 2
%22 = tail call i8* @malloc(i32 %21)
%23 = icmp eq i8* %22, null
br i1 %23, label %43, label %24
24: ; preds = %19
store i8 0, i8* %22
%25 = tail call %struct.t_weelist_item* @weelist_get(%struct.t_weelist* %1, i32 0)
%26 = icmp eq %struct.t_weelist_item* %25, null
br i1 %26, label %40, label %27
27: ; preds = %24, %37
%28 = phi %struct.t_weelist_item* [ %38, %37 ], [ %25, %24 ]
%29 = tail call i8* @weelist_string(%struct.t_weelist_item* %28)
%30 = icmp eq i8* %29, null
br i1 %30, label %37, label %31
31: ; preds = %27
%32 = tail call i32 @strcat(i8* %22, i8* %29)
%33 = tail call %struct.t_weelist_item* @weelist_next(%struct.t_weelist_item* %28)
%34 = icmp eq %struct.t_weelist_item* %33, null
br i1 %34, label %37, label %35
35: ; preds = %31
%36 = tail call i32 @strcat(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %37
37: ; preds = %27, %35, %31
%38 = tail call %struct.t_weelist_item* @weelist_next(%struct.t_weelist_item* %28)
%39 = icmp eq %struct.t_weelist_item* %38, null
br i1 %39, label %40, label %27
40: ; preds = %37, %24
%41 = tail call i32 @gui_buffer_set_highlight_words(%struct.t_gui_buffer* %0, i8* %22)
%42 = tail call i32 @free(i8* %22)
br label %43
43: ; preds = %19, %40
ret void
}