#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*/ EINVAL;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(char **);
char **mx_strvec_new();
int mx_strvec_push_str(char ***, char *);
char *strstr(char *, char *);
char **mx_strvec_from_str(char *str) {
  int res;
  char *s;
  char *p;
  char **strvec;
  strvec = mx_strvec_new();
  if (!strvec)
    return NULL;
  for (s = str; *s; s = p + 2) {
    p = strstr(s, "\\0");
    if (!p) {
      free(strvec);
      errno = EINVAL;
      return NULL;
    }
    *p = 0;
    res = mx_strvec_push_str(&strvec, s);
    if (!res) {
      free(strvec);
      return NULL;
    }
  }
  return strvec;
}


x86 assembly (clang, -O0):
<mx_strvec_from_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1060 <mx_strvec_new@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    116f <mx_strvec_from_str+0x2f>
movq   $0x0,-0x8(%rbp)
jmp    1220 <mx_strvec_from_str+0xe0>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     1218 <mx_strvec_from_str+0xd8>
mov    -0x20(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11cb <mx_strvec_from_str+0x8b>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e25(%rip),%rax
mov    (%rax),%ecx
mov    0x2e24(%rip),%rax
mov    %ecx,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1220 <mx_strvec_from_str+0xe0>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rsi
lea    -0x30(%rbp),%rdi
call   1040 <mx_strvec_push_str@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1202 <mx_strvec_from_str+0xc2>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1220 <mx_strvec_from_str+0xe0>
jmp    1207 <mx_strvec_from_str+0xc7>
mov    -0x28(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x20(%rbp)
jmp    1177 <mx_strvec_from_str+0x37>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mx_strvec_from_str>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r12
xor    %r14d,%r14d
xor    %eax,%eax
call   1060 <mx_strvec_new@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     11d5 <mx_strvec_from_str+0x95>
cmpb   $0x0,(%r12)
je     11a7 <mx_strvec_from_str+0x67>
lea    0xe94(%rip),%r14
mov    %rsp,%r15
nop
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     11ac <mx_strvec_from_str+0x6c>
mov    %rax,%rbx
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <mx_strvec_push_str@plt>
test   %eax,%eax
je     11c9 <mx_strvec_from_str+0x89>
add    $0x2,%rbx
cmpb   $0x0,(%rbx)
mov    %rbx,%r12
jne    1170 <mx_strvec_from_str+0x30>
mov    (%rsp),%r14
jmp    11d5 <mx_strvec_from_str+0x95>
mov    %rax,%r14
jmp    11d5 <mx_strvec_from_str+0x95>
mov    (%rsp),%rdi
call   1030 <free@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%eax
mov    0x2e1b(%rip),%rcx
mov    %eax,(%rcx)
jmp    11d2 <mx_strvec_from_str+0x92>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"\\0\00"
@EINVAL = global i32 0
@errno = global i32 0
define i8** @mx_strvec_from_str(i8* %0) {
%2 = alloca i8**
%3 = bitcast i8*** %2 to i8*
%4 = tail call i8** (...) @mx_strvec_new()
store i8** %4, i8*** %2
%5 = icmp eq i8** %4, null
br i1 %5, label %29, label %6
6: ; preds = %1
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %29, label %12
9: ; preds = %20
%10 = load i8, i8* %23
%11 = icmp eq i8 %10, 0
br i1 %11, label %27, label %12
12: ; preds = %6, %9
%13 = phi i8* [ %23, %9 ], [ %0, %6 ]
%14 = call i8* @strstr(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i8**, i8*** %2
%18 = call i32 @free(i8** %17)
%19 = load i32, i32* @EINVAL
store i32 %19, i32* @errno
br label %29
20: ; preds = %12
store i8 0, i8* %14
%21 = call i32 @mx_strvec_push_str(i8*** %2, i8* %13)
%22 = icmp eq i32 %21, 0
%23 = getelementptr inbounds i8, i8* %14, i64 2
br i1 %22, label %24, label %9
24: ; preds = %20
%25 = load i8**, i8*** %2
%26 = call i32 @free(i8** %25)
br label %29
27: ; preds = %9
%28 = load i8**, i8*** %2
br label %29
29: ; preds = %6, %27, %1, %24, %16
%30 = phi i8** [ null, %24 ], [ null, %16 ], [ null, %1 ], [ %28, %27 ], [ %4, %6 ]
ret i8** %30
}