#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 */
typedef struct string const string;
struct list {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ is_blank(char const);
int /*<<< orphan*/ list_clear(struct list *);
int /*<<< orphan*/ list_push_back(struct list *, struct string const *);
int /*<<< orphan*/ string_append_char(struct string const *, char const);
int /*<<< orphan*/ string_destroy(struct string const *);
char *string_get_cstr(struct string const *);
scalar_t__ string_get_size(struct string const *);
struct string const *string_init(char *);
void get_token_list(const struct string *string, struct list *tokens) {
  const char *cstr = string_get_cstr(string);
  size_t size = string_get_size(string);
  struct string *token = string_init("");
  size_t i;
  list_clear(tokens);
  for (i = 0; i < size; ++i) {
    if (!is_blank(cstr[i])) {
      string_append_char(token, cstr[i]);
    } else if (string_get_size(token) != 0) {
      list_push_back(tokens, token);
      token = string_init("");
    }
  }
  if (string_get_size(token) != 0) {
    list_push_back(tokens, token);
  } else {
    string_destroy(token);
  }
}


x86 assembly (clang, -O0):
<get_token_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   10a0 <string_get_cstr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <string_get_size@plt>
mov    %rax,-0x20(%rbp)
lea    0xe4f(%rip),%rdi
call   1040 <string_init@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <list_clear@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1258 <get_token_list+0xd8>
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1080 <is_blank@plt>
cmp    $0x0,%eax
jne    120d <get_token_list+0x8d>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x30(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
call   1050 <string_append_char@plt>
jmp    1242 <get_token_list+0xc2>
mov    -0x28(%rbp),%rdi
call   1070 <string_get_size@plt>
cmp    $0x0,%rax
je     123d <get_token_list+0xbd>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <list_push_back@plt>
lea    0xdcc(%rip),%rdi
call   1040 <string_init@plt>
mov    %rax,-0x28(%rbp)
jmp    1242 <get_token_list+0xc2>
jmp    1247 <get_token_list+0xc7>
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    11cb <get_token_list+0x4b>
mov    -0x28(%rbp),%rdi
call   1070 <string_get_size@plt>
cmp    $0x0,%rax
je     127d <get_token_list+0xfd>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <list_push_back@plt>
jmp    1286 <get_token_list+0x106>
mov    -0x28(%rbp),%rdi
call   1060 <string_destroy@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_token_list>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   10a0 <string_get_cstr@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1070 <string_get_size@plt>
mov    %rax,%r12
lea    0xe55(%rip),%rdi
call   1040 <string_init@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1090 <list_clear@plt>
test   %r12,%r12
je     1219 <get_token_list+0x99>
xor    %ebp,%ebp
lea    0xe37(%rip),%r13
jmp    11e6 <get_token_list+0x66>
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbp,1),%esi
mov    %rbx,%rdi
call   1050 <string_append_char@plt>
add    $0x1,%rbp
cmp    %rbp,%r12
je     1219 <get_token_list+0x99>
movsbl (%r15,%rbp,1),%edi
call   1080 <is_blank@plt>
test   %eax,%eax
je     11d0 <get_token_list+0x50>
mov    %rbx,%rdi
call   1070 <string_get_size@plt>
test   %rax,%rax
je     11dd <get_token_list+0x5d>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <list_push_back@plt>
mov    %r13,%rdi
call   1040 <string_init@plt>
mov    %rax,%rbx
jmp    11dd <get_token_list+0x5d>
mov    %rbx,%rdi
call   1070 <string_get_size@plt>
test   %rax,%rax
je     123f <get_token_list+0xbf>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <list_push_back@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <string_destroy@plt>

LLVM IR (-O0):
%struct.string = type opaque
%struct.list = type { i32 }
@.str = [1 x i8] zeroinitializer
define void @get_token_list(%struct.string* %0, %struct.list* %1) {
%3 = alloca %struct.string*
%4 = alloca %struct.list*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca %struct.string*
%8 = alloca i64
store %struct.string* %0, %struct.string** %3
store %struct.list* %1, %struct.list** %4
%9 = load %struct.string*, %struct.string** %3
%10 = call i8* @string_get_cstr(%struct.string* %9)
store i8* %10, i8** %5
%11 = load %struct.string*, %struct.string** %3
%12 = call i64 @string_get_size(%struct.string* %11)
store i64 %12, i64* %6
%13 = call %struct.string* @string_init(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store %struct.string* %13, %struct.string** %7
%14 = load %struct.list*, %struct.list** %4
%15 = call i32 @list_clear(%struct.list* %14)
store i64 0, i64* %8
br label %16
16: ; preds = %45, %2
%17 = load i64, i64* %8
%18 = load i64, i64* %6
%19 = icmp ult i64 %17, %18
br i1 %19, label %20, label %48
20: ; preds = %16
%21 = load i8*, i8** %5
%22 = load i64, i64* %8
%23 = getelementptr inbounds i8, i8* %21, i64 %22
%24 = load i8, i8* %23
%25 = call i32 @is_blank(i8 signext %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %34, label %27
27: ; preds = %20
%28 = load %struct.string*, %struct.string** %7
%29 = load i8*, i8** %5
%30 = load i64, i64* %8
%31 = getelementptr inbounds i8, i8* %29, i64 %30
%32 = load i8, i8* %31
%33 = call i32 @string_append_char(%struct.string* %28, i8 signext %32)
br label %44
34: ; preds = %20
%35 = load %struct.string*, %struct.string** %7
%36 = call i64 @string_get_size(%struct.string* %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load %struct.list*, %struct.list** %4
%40 = load %struct.string*, %struct.string** %7
%41 = call i32 @list_push_back(%struct.list* %39, %struct.string* %40)
%42 = call %struct.string* @string_init(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
store %struct.string* %42, %struct.string** %7
br label %43
43: ; preds = %38, %34
br label %44
44: ; preds = %43, %27
br label %45
45: ; preds = %44
%46 = load i64, i64* %8
%47 = add i64 %46, 1
store i64 %47, i64* %8
br label %16
48: ; preds = %16
%49 = load %struct.string*, %struct.string** %7
%50 = call i64 @string_get_size(%struct.string* %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %56
52: ; preds = %48
%53 = load %struct.list*, %struct.list** %4
%54 = load %struct.string*, %struct.string** %7
%55 = call i32 @list_push_back(%struct.list* %53, %struct.string* %54)
br label %59
56: ; preds = %48
%57 = load %struct.string*, %struct.string** %7
%58 = call i32 @string_destroy(%struct.string* %57)
br label %59
59: ; preds = %56, %52
ret void
}

LLVM IR (-O2):
%struct.string = type opaque
%struct.list = type { i32 }
@.str = [1 x i8] zeroinitializer
define void @get_token_list(%struct.string* %0, %struct.list* %1) {
%3 = tail call i8* @string_get_cstr(%struct.string* %0)
%4 = tail call i64 @string_get_size(%struct.string* %0)
%5 = tail call %struct.string* @string_init(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @list_clear(%struct.list* %1)
%7 = icmp eq i64 %4, 0
br i1 %7, label %28, label %8
8: ; preds = %2, %24
%9 = phi i64 [ %26, %24 ], [ 0, %2 ]
%10 = phi %struct.string* [ %25, %24 ], [ %5, %2 ]
%11 = getelementptr inbounds i8, i8* %3, i64 %9
%12 = load i8, i8* %11
%13 = tail call i32 @is_blank(i8 signext %12)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %8
%16 = load i8, i8* %11
%17 = tail call i32 @string_append_char(%struct.string* %10, i8 signext %16)
br label %24
18: ; preds = %8
%19 = tail call i64 @string_get_size(%struct.string* %10)
%20 = icmp eq i64 %19, 0
br i1 %20, label %24, label %21
21: ; preds = %18
%22 = tail call i32 @list_push_back(%struct.list* %1, %struct.string* %10)
%23 = tail call %struct.string* @string_init(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
br label %24
24: ; preds = %15, %21, %18
%25 = phi %struct.string* [ %23, %21 ], [ %10, %18 ], [ %10, %15 ]
%26 = add nuw i64 %9, 1
%27 = icmp eq i64 %26, %4
br i1 %27, label %28, label %8
28: ; preds = %24, %2
%29 = phi %struct.string* [ %5, %2 ], [ %25, %24 ]
%30 = tail call i64 @string_get_size(%struct.string* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %34, label %32
32: ; preds = %28
%33 = tail call i32 @list_push_back(%struct.list* %1, %struct.string* %29)
br label %36
34: ; preds = %28
%35 = tail call i32 @string_destroy(%struct.string* %29)
br label %36
36: ; preds = %34, %32
ret void
}