#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 */
char **calloc(int, int);
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;
  if (length_value == 0)
    return calloc(1, sizeof(char *));
  char *value_without_brackets = string_substring(text, 1, length_value);
  char **array_values = string_split(value_without_brackets, ",");
  for (int i = 0; array_values[i] != NULL; i++) {
    string_trim(&(array_values[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,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x2,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    119d <string_get_string_as_array+0x3d>
mov    $0x1,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x8(%rbp)
jmp    1213 <string_get_string_as_array+0xb3>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    $0x1,%esi
call   1080 <string_substring@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1060 <string_split@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     1202 <string_get_string_as_array+0xa2>
mov    -0x28(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rdi
call   1070 <string_trim@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11cd <string_get_string_as_array+0x6d>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%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>
add    $0xfffffffe,%eax
je     11c4 <string_get_string_as_array+0x64>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1080 <string_substring@plt>
mov    %rax,%r14
lea    0xe75(%rip),%rsi
mov    %rax,%rdi
call   1060 <string_split@plt>
mov    %rax,%r15
cmpq   $0x0,(%rax)
je     11b3 <string_get_string_as_array+0x53>
mov    %r15,%rbx
nop
mov    %rbx,%rdi
call   1070 <string_trim@plt>
cmpq   $0x0,0x8(%rbx)
lea    0x8(%rbx),%rbx
jne    11a0 <string_get_string_as_array+0x40>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
mov    $0x8,%esi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <calloc@plt>

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

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 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i8** @calloc(i32 1, i32 8)
br label %22
7: ; preds = %1
%8 = tail call i8* @string_substring(i8* %0, i32 1, i32 %3)
%9 = tail call i8** @string_split(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %9
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %14, %7
%13 = tail call i32 @free(i8* %8)
br label %22
14: ; preds = %7, %14
%15 = phi i64 [ %18, %14 ], [ 0, %7 ]
%16 = phi i8** [ %19, %14 ], [ %9, %7 ]
%17 = tail call i32 @string_trim(i8** %16)
%18 = add nuw i64 %15, 1
%19 = getelementptr inbounds i8*, i8** %9, i64 %18
%20 = load i8*, i8** %19
%21 = icmp eq i8* %20, null
br i1 %21, label %12, label %14
22: ; preds = %12, %5
%23 = phi i8** [ %6, %5 ], [ %9, %12 ]
ret i8** %23
}