#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 */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
char **string_split(char *, char *);
char *string_substring(char *, int, int);
int /*<<< orphan*/ string_trim(char **);
int strlen(char *);
char **string_get_string_as_array(char *text) {
  int length_value = strlen(text) - 2;
  char *value_without_brackets = string_substring(text, 1, length_value);
  char **array_values = string_split(value_without_brackets, ",");
  int i = 0;
  while (array_values[i] != NULL) {
    string_trim(&(array_values[i]));
    i++;
  }
  free(value_without_brackets);
  return array_values;
}


x86 assembly (clang, -O0):
<string_get_string_as_array>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    $0x1,%esi
call   1070 <string_substring@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe75(%rip),%rsi
call   1050 <string_split@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11d0 <string_get_string_as_array+0x80>
mov    -0x20(%rbp),%rdi
movslq -0x24(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1060 <string_trim@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    119b <string_get_string_as_array+0x4b>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<string_get_string_as_array>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1040 <strlen@plt>
lea    -0x2(%rax),%edx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1070 <string_substring@plt>
mov    %rax,%r14
lea    0xe89(%rip),%rsi
mov    %rax,%rdi
call   1050 <string_split@plt>
mov    %rax,%r15
cmpq   $0x0,(%rax)
je     11a3 <string_get_string_as_array+0x53>
mov    %r15,%rbx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1060 <string_trim@plt>
cmpq   $0x0,0x8(%rbx)
lea    0x8(%rbx),%rbx
jne    1190 <string_get_string_as_array+0x40>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c",\00"
define i8** @string_get_string_as_array(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, -2
%4 = tail call i8* @string_substring(i8* %0, i32 1, i32 %3)
%5 = tail call i8** @string_split(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %16, label %8
8: ; preds = %1, %8
%9 = phi i64 [ %12, %8 ], [ 0, %1 ]
%10 = phi i8** [ %13, %8 ], [ %5, %1 ]
%11 = tail call i32 @string_trim(i8** %10)
%12 = add nuw i64 %9, 1
%13 = getelementptr inbounds i8*, i8** %5, i64 %12
%14 = load i8*, i8** %13
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %8
16: ; preds = %8, %1
%17 = tail call i32 @free(i8* %4)
ret i8** %5
}