#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;
scalar_t__ _popen_noshell_add_token(char ***, int *, char *, char *, int *);
scalar_t__ calloc(int, int);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ free(char **);
int /*<<< orphan*/ *index(char const *, char);
scalar_t__ popen_noshell_add_ptr_to_argv(char ***, int *, int /*<<< orphan*/ *);
int strlen(char const *);
char **popen_noshell_split_command_to_argv(const char *command_original,
                                           char **free_this_buf) {
  char *command;
  size_t i, len;
  char *start = NULL;
  char c;
  char **argv = NULL;
  int count = 0;
  const char _popen_bash_meta_characters[] = "!\\$`\n|&;()<>";
  int in_sq = 0;
  int in_dq = 0;
  int j = 0;
  command = (char *)calloc(strlen(command_original) + 1, sizeof(char));
  *free_this_buf = command;
  if (!command) {
    free(argv);
    return NULL;
  };
  len = strlen(command_original);
  j = 0;
  for (i = 0; i < len; ++i) {
    if (!start)
      start = command + j;
    c = command_original[i];
    if (index(_popen_bash_meta_characters, c) != NULL) {
      errno = EINVAL;
      {
        free(argv);
        return NULL;
      };
    }
    if (c == ' ' || c == '\t') {
      if (in_sq || in_dq) {
        command[j++] = c;
        continue;
      }
      if (_popen_noshell_add_token(&argv, &count, start, command, &j) != 0) {
        {
          free(argv);
          return NULL;
        };
      }
      start = NULL;
      continue;
    }
    if (c == '\'' && !in_dq) {
      in_sq = !in_sq;
      continue;
    }
    if (c == '"' && !in_sq) {
      in_dq = !in_dq;
      continue;
    }
    command[j++] = c;
  }
  if (in_sq || in_dq) {
    errno = EINVAL;
    {
      free(argv);
      return NULL;
    };
  }
  if (_popen_noshell_add_token(&argv, &count, start, command, &j) != 0) {
    {
      free(argv);
      return NULL;
    };
  }
  if (count == 0) {
    errno = EINVAL;
    {
      free(argv);
      return NULL;
    };
  }
  if (popen_noshell_add_ptr_to_argv(&argv, &count, NULL) != 0) {
    {
      free(argv);
      return NULL;
    };
  }
  return argv;
}


x86 assembly (clang, -O0):
<popen_noshell_split_command_to_argv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
mov    0xe72(%rip),%rax
mov    %rax,-0x59(%rbp)
mov    0xe70(%rip),%eax
mov    %eax,-0x51(%rbp)
mov    0xe6b(%rip),%al
mov    %al,-0x4d(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x68(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x20(%rbp)
jne    1201 <popen_noshell_split_command_to_argv+0xa1>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1488 <popen_noshell_split_command_to_argv+0x328>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
cltq
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x68(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    13a8 <popen_noshell_split_command_to_argv+0x248>
cmpq   $0x0,-0x38(%rbp)
jne    1247 <popen_noshell_split_command_to_argv+0xe7>
mov    -0x20(%rbp),%rax
movslq -0x68(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x39(%rbp)
lea    -0x59(%rbp),%rdi
movsbl -0x39(%rbp),%esi
call   1070 <index@plt>
cmp    $0x0,%rax
je     1294 <popen_noshell_split_command_to_argv+0x134>
mov    0x2d65(%rip),%rax
mov    (%rax),%ecx
mov    0x2d64(%rip),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1488 <popen_noshell_split_command_to_argv+0x328>
movsbl -0x39(%rbp),%eax
cmp    $0x20,%eax
je     12ae <popen_noshell_split_command_to_argv+0x14e>
movsbl -0x39(%rbp),%eax
cmp    $0x9,%eax
jne    1325 <popen_noshell_split_command_to_argv+0x1c5>
cmpl   $0x0,-0x60(%rbp)
jne    12c2 <popen_noshell_split_command_to_argv+0x162>
cmpl   $0x0,-0x64(%rbp)
je     12df <popen_noshell_split_command_to_argv+0x17f>
mov    -0x39(%rbp),%dl
mov    -0x20(%rbp),%rax
mov    -0x68(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x68(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1397 <popen_noshell_split_command_to_argv+0x237>
mov    -0x38(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x48(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
lea    -0x68(%rbp),%r8
call   1040 <_popen_noshell_add_token@plt>
cmp    $0x0,%rax
je     1318 <popen_noshell_split_command_to_argv+0x1b8>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1488 <popen_noshell_split_command_to_argv+0x328>
movq   $0x0,-0x38(%rbp)
jmp    1397 <popen_noshell_split_command_to_argv+0x237>
movsbl -0x39(%rbp),%eax
cmp    $0x27,%eax
jne    1352 <popen_noshell_split_command_to_argv+0x1f2>
cmpl   $0x0,-0x64(%rbp)
jne    1352 <popen_noshell_split_command_to_argv+0x1f2>
cmpl   $0x0,-0x60(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x60(%rbp)
jmp    1397 <popen_noshell_split_command_to_argv+0x237>
movsbl -0x39(%rbp),%eax
cmp    $0x22,%eax
jne    137f <popen_noshell_split_command_to_argv+0x21f>
cmpl   $0x0,-0x60(%rbp)
jne    137f <popen_noshell_split_command_to_argv+0x21f>
cmpl   $0x0,-0x64(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x64(%rbp)
jmp    1397 <popen_noshell_split_command_to_argv+0x237>
mov    -0x39(%rbp),%dl
mov    -0x20(%rbp),%rax
mov    -0x68(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x68(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    121f <popen_noshell_split_command_to_argv+0xbf>
cmpl   $0x0,-0x60(%rbp)
jne    13bc <popen_noshell_split_command_to_argv+0x25c>
cmpl   $0x0,-0x64(%rbp)
je     13e4 <popen_noshell_split_command_to_argv+0x284>
mov    0x2c15(%rip),%rax
mov    (%rax),%ecx
mov    0x2c14(%rip),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1488 <popen_noshell_split_command_to_argv+0x328>
mov    -0x38(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    -0x48(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
lea    -0x68(%rbp),%r8
call   1040 <_popen_noshell_add_token@plt>
cmp    $0x0,%rax
je     141d <popen_noshell_split_command_to_argv+0x2bd>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1488 <popen_noshell_split_command_to_argv+0x328>
cmpl   $0x0,-0x4c(%rbp)
jne    144f <popen_noshell_split_command_to_argv+0x2ef>
mov    0x2baa(%rip),%rax
mov    (%rax),%ecx
mov    0x2ba9(%rip),%rax
mov    %ecx,(%rax)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1488 <popen_noshell_split_command_to_argv+0x328>
lea    -0x48(%rbp),%rdi
lea    -0x4c(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <popen_noshell_add_ptr_to_argv@plt>
cmp    $0x0,%rax
je     1480 <popen_noshell_split_command_to_argv+0x320>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1488 <popen_noshell_split_command_to_argv+0x328>
mov    -0x48(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<popen_noshell_split_command_to_argv>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%rbx
mov    %rdi,%rbp
movq   $0x0,0x8(%rsp)
movl   $0x0,0x14(%rsp)
movabs $0x3e3c29283b267c,%rax
mov    %rax,0x1d(%rsp)
movabs $0x3b267c0a60245c21,%rax
7c 26 3b
mov    %rax,0x18(%rsp)
call   1050 <strlen@plt>
lea    0x1(%rax),%edi
mov    $0x1,%esi
call   1080 <calloc@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     1326 <popen_noshell_split_command_to_argv+0x1c6>
mov    %rax,%r15
mov    %rbp,%rdi
call   1050 <strlen@plt>
movl   $0x0,0x4(%rsp)
test   %eax,%eax
je     1331 <popen_noshell_split_command_to_argv+0x1d1>
mov    %eax,%ebx
mov    %rbp,0x30(%rsp)
mov    0x0(%rbp),%r14b
movsbl %r14b,%esi
lea    0x18(%rsp),%rdi
call   1070 <index@plt>
test   %rax,%rax
jne    133e <popen_noshell_split_command_to_argv+0x1de>
movslq %ebx,%rax
mov    %rax,0x28(%rsp)
xor    %r12d,%r12d
mov    $0x1,%ebp
mov    %r15,%rbx
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x20,%r14b
je     122c <popen_noshell_split_command_to_argv+0xcc>
cmp    $0x9,%r14b
jne    1260 <popen_noshell_split_command_to_argv+0x100>
mov    %r12d,%eax
or     %r13d,%eax
je     1290 <popen_noshell_split_command_to_argv+0x130>
movslq 0x4(%rsp),%rax
lea    0x1(%rax),%ecx
mov    %ecx,0x4(%rsp)
mov    %r14b,(%r15,%rax,1)
cmp    %rbp,0x28(%rsp)
jne    12f0 <popen_noshell_split_command_to_argv+0x190>
jmp    1339 <popen_noshell_split_command_to_argv+0x1d9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x27,%r14b
jne    12c4 <popen_noshell_split_command_to_argv+0x164>
test   %r13d,%r13d
jne    12c4 <popen_noshell_split_command_to_argv+0x164>
xor    %eax,%eax
test   %r12d,%r12d
sete   %al
xor    %r13d,%r13d
mov    %eax,%r12d
cmp    %rbp,0x28(%rsp)
jne    12f0 <popen_noshell_split_command_to_argv+0x190>
jmp    1339 <popen_noshell_split_command_to_argv+0x1d9>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0x8(%rsp),%rdi
lea    0x14(%rsp),%rsi
mov    %rbx,%rdx
mov    %r15,%rcx
lea    0x4(%rsp),%r8
call   1040 <_popen_noshell_add_token@plt>
test   %rax,%rax
jne    1350 <popen_noshell_split_command_to_argv+0x1f0>
xor    %ebx,%ebx
xor    %r12d,%r12d
xor    %r13d,%r13d
cmp    %rbp,0x28(%rsp)
jne    12f0 <popen_noshell_split_command_to_argv+0x190>
jmp    1339 <popen_noshell_split_command_to_argv+0x1d9>
cmp    $0x22,%r14b
jne    1234 <popen_noshell_split_command_to_argv+0xd4>
test   %r12d,%r12d
jne    1234 <popen_noshell_split_command_to_argv+0xd4>
xor    %eax,%eax
test   %r13d,%r13d
sete   %al
xor    %r12d,%r12d
mov    %eax,%r13d
cmp    %rbp,0x28(%rsp)
je     1339 <popen_noshell_split_command_to_argv+0x1d9>
nopl   0x0(%rax)
movslq 0x4(%rsp),%rax
add    %r15,%rax
test   %rbx,%rbx
cmove  %rax,%rbx
mov    0x30(%rsp),%rax
movzbl (%rax,%rbp,1),%r14d
movsbl %r14b,%esi
lea    0x18(%rsp),%rdi
call   1070 <index@plt>
add    $0x1,%rbp
test   %rax,%rax
je     1220 <popen_noshell_split_command_to_argv+0xc0>
jmp    133e <popen_noshell_split_command_to_argv+0x1de>
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <free@plt>
jmp    135c <popen_noshell_split_command_to_argv+0x1fc>
xor    %ebx,%ebx
xor    %r12d,%r12d
xor    %r13d,%r13d
or     %r13d,%r12d
je     136e <popen_noshell_split_command_to_argv+0x20e>
mov    0x2c93(%rip),%rax
mov    (%rax),%eax
mov    0x2c92(%rip),%rcx
mov    %eax,(%rcx)
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x8(%rsp),%rdi
lea    0x14(%rsp),%rsi
lea    0x4(%rsp),%r8
mov    %rbx,%rdx
mov    %r15,%rcx
call   1040 <_popen_noshell_add_token@plt>
test   %rax,%rax
jne    1350 <popen_noshell_split_command_to_argv+0x1f0>
cmpl   $0x0,0x14(%rsp)
je     133e <popen_noshell_split_command_to_argv+0x1de>
lea    0x8(%rsp),%rdi
lea    0x14(%rsp),%rsi
xor    %edx,%edx
call   1060 <popen_noshell_add_ptr_to_argv@plt>
mov    0x8(%rsp),%rbx
test   %rax,%rax
je     135c <popen_noshell_split_command_to_argv+0x1fc>
mov    %rbx,%rdi
jmp    1355 <popen_noshell_split_command_to_argv+0x1f5>

LLVM IR (-O0):
@__const.popen_noshell_split_command_to_argv._popen_bash_meta_characters = [13 x i8] c"!\\$`\0A|&;()<>\00"
@EINVAL = global i32 0
@errno = global i32 0
define i8** @popen_noshell_split_command_to_argv(i8* %0, i8** %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8*
%10 = alloca i8
%11 = alloca i8**
%12 = alloca i32
%13 = alloca [13 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %4
store i8** %1, i8*** %5
store i8* null, i8** %9
store i8** null, i8*** %11
store i32 0, i32* %12
%17 = bitcast [13 x i8]* %13 to i8*
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
%18 = load i8*, i8** %4
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %19, 1
%21 = call i64 @calloc(i32 %20, i32 1)
%22 = inttoptr i64 %21 to i8*
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = load i8**, i8*** %5
store i8* %23, i8** %24
%25 = load i8*, i8** %6
%26 = icmp ne i8* %25, null
br i1 %26, label %30, label %27
27: ; preds = %2
%28 = load i8**, i8*** %11
%29 = call i32 @free(i8** %28)
store i8** null, i8*** %3
br label %156
30: ; preds = %2
%31 = load i8*, i8** %4
%32 = call i32 @strlen(i8* %31)
%33 = sext i32 %32 to i64
store i64 %33, i64* %8
store i32 0, i32* %16
store i64 0, i64* %7
br label %34
34: ; preds = %120, %30
%35 = load i64, i64* %7
%36 = load i64, i64* %8
%37 = icmp ult i64 %35, %36
br i1 %37, label %38, label %123
38: ; preds = %34
%39 = load i8*, i8** %9
%40 = icmp ne i8* %39, null
br i1 %40, label %46, label %41
41: ; preds = %38
%42 = load i8*, i8** %6
%43 = load i32, i32* %16
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %42, i64 %44
store i8* %45, i8** %9
br label %46
46: ; preds = %41, %38
%47 = load i8*, i8** %4
%48 = load i64, i64* %7
%49 = getelementptr inbounds i8, i8* %47, i64 %48
%50 = load i8, i8* %49
store i8 %50, i8* %10
%51 = getelementptr inbounds [13 x i8], [13 x i8]* %13, i64 0, i64 0
%52 = load i8, i8* %10
%53 = call i32* @index(i8* %51, i8 signext %52)
%54 = icmp ne i32* %53, null
br i1 %54, label %55, label %59
55: ; preds = %46
%56 = load i32, i32* @EINVAL
store i32 %56, i32* @errno
%57 = load i8**, i8*** %11
%58 = call i32 @free(i8** %57)
store i8** null, i8*** %3
br label %156
59: ; preds = %46
%60 = load i8, i8* %10
%61 = sext i8 %60 to i32
%62 = icmp eq i32 %61, 32
br i1 %62, label %67, label %63
63: ; preds = %59
%64 = load i8, i8* %10
%65 = sext i8 %64 to i32
%66 = icmp eq i32 %65, 9
br i1 %66, label %67, label %89
67: ; preds = %63, %59
%68 = load i32, i32* %14
%69 = icmp ne i32 %68, 0
br i1 %69, label %73, label %70
70: ; preds = %67
%71 = load i32, i32* %15
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %80
73: ; preds = %70, %67
%74 = load i8, i8* %10
%75 = load i8*, i8** %6
%76 = load i32, i32* %16
%77 = add nsw i32 %76, 1
store i32 %77, i32* %16
%78 = sext i32 %76 to i64
%79 = getelementptr inbounds i8, i8* %75, i64 %78
store i8 %74, i8* %79
br label %120
80: ; preds = %70
%81 = load i8*, i8** %9
%82 = load i8*, i8** %6
%83 = call i64 @_popen_noshell_add_token(i8*** %11, i32* %12, i8* %81, i8* %82, i32* %16)
%84 = icmp ne i64 %83, 0
br i1 %84, label %85, label %88
85: ; preds = %80
%86 = load i8**, i8*** %11
%87 = call i32 @free(i8** %86)
store i8** null, i8*** %3
br label %156
88: ; preds = %80
store i8* null, i8** %9
br label %120
89: ; preds = %63
%90 = load i8, i8* %10
%91 = sext i8 %90 to i32
%92 = icmp eq i32 %91, 39
br i1 %92, label %93, label %101
93: ; preds = %89
%94 = load i32, i32* %15
%95 = icmp ne i32 %94, 0
br i1 %95, label %101, label %96
96: ; preds = %93
%97 = load i32, i32* %14
%98 = icmp ne i32 %97, 0
%99 = xor i1 %98, true
%100 = zext i1 %99 to i32
store i32 %100, i32* %14
br label %120
101: ; preds = %93, %89
%102 = load i8, i8* %10
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 34
br i1 %104, label %105, label %113
105: ; preds = %101
%106 = load i32, i32* %14
%107 = icmp ne i32 %106, 0
br i1 %107, label %113, label %108
108: ; preds = %105
%109 = load i32, i32* %15
%110 = icmp ne i32 %109, 0
%111 = xor i1 %110, true
%112 = zext i1 %111 to i32
store i32 %112, i32* %15
br label %120
113: ; preds = %105, %101
%114 = load i8, i8* %10
%115 = load i8*, i8** %6
%116 = load i32, i32* %16
%117 = add nsw i32 %116, 1
store i32 %117, i32* %16
%118 = sext i32 %116 to i64
%119 = getelementptr inbounds i8, i8* %115, i64 %118
store i8 %114, i8* %119
br label %120
120: ; preds = %113, %108, %96, %88, %73
%121 = load i64, i64* %7
%122 = add i64 %121, 1
store i64 %122, i64* %7
br label %34
123: ; preds = %34
%124 = load i32, i32* %14
%125 = icmp ne i32 %124, 0
br i1 %125, label %129, label %126
126: ; preds = %123
%127 = load i32, i32* %15
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %133
129: ; preds = %126, %123
%130 = load i32, i32* @EINVAL
store i32 %130, i32* @errno
%131 = load i8**, i8*** %11
%132 = call i32 @free(i8** %131)
store i8** null, i8*** %3
br label %156
133: ; preds = %126
%134 = load i8*, i8** %9
%135 = load i8*, i8** %6
%136 = call i64 @_popen_noshell_add_token(i8*** %11, i32* %12, i8* %134, i8* %135, i32* %16)
%137 = icmp ne i64 %136, 0
br i1 %137, label %138, label %141
138: ; preds = %133
%139 = load i8**, i8*** %11
%140 = call i32 @free(i8** %139)
store i8** null, i8*** %3
br label %156
141: ; preds = %133
%142 = load i32, i32* %12
%143 = icmp eq i32 %142, 0
br i1 %143, label %144, label %148
144: ; preds = %141
%145 = load i32, i32* @EINVAL
store i32 %145, i32* @errno
%146 = load i8**, i8*** %11
%147 = call i32 @free(i8** %146)
store i8** null, i8*** %3
br label %156
148: ; preds = %141
%149 = call i64 @popen_noshell_add_ptr_to_argv(i8*** %11, i32* %12, i32* null)
%150 = icmp ne i64 %149, 0
br i1 %150, label %151, label %154
151: ; preds = %148
%152 = load i8**, i8*** %11
%153 = call i32 @free(i8** %152)
store i8** null, i8*** %3
br label %156
154: ; preds = %148
%155 = load i8**, i8*** %11
store i8** %155, i8*** %3
br label %156
156: ; preds = %154, %151, %144, %138, %129, %85, %55, %27
%157 = load i8**, i8*** %3
ret i8** %157
}

LLVM IR (-O2):
@__const.popen_noshell_split_command_to_argv._popen_bash_meta_characters = [13 x i8] c"!\\$`\0A|&;()<>\00"
@EINVAL = global i32 0
@errno = global i32 0
define i8** @popen_noshell_split_command_to_argv(i8* %0, i8** nocapture writeonly %1) {
%3 = alloca i8**
%4 = alloca i32
%5 = alloca [13 x i8]
%6 = alloca i32
%7 = bitcast i8*** %3 to i8*
store i8** null, i8*** %3
%8 = bitcast i32* %4 to i8*
store i32 0, i32* %4
%9 = getelementptr inbounds [13 x i8], [13 x i8]* %5, i64 0, i64 0
%10 = bitcast i32* %6 to i8*
%11 = tail call i32 @strlen(i8* %0)
%12 = add nsw i32 %11, 1
%13 = tail call i64 @calloc(i32 %12, i32 1)
%14 = inttoptr i64 %13 to i8*
store i8* %14, i8** %1
%15 = icmp eq i64 %13, 0
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = tail call i32 @free(i8** null)
br label %116
18: ; preds = %2
%19 = tail call i32 @strlen(i8* %0)
store i32 0, i32* %6
%20 = icmp eq i32 %19, 0
br i1 %20, label %86, label %21
21: ; preds = %18
%22 = sext i32 %19 to i64
%23 = load i8, i8* %0
%24 = call i32* @index(i8* %9, i8 signext %23)
%25 = icmp eq i32* %24, null
br i1 %25, label %30, label %26
26: ; preds = %76, %21
%27 = load i32, i32* @EINVAL
store i32 %27, i32* @errno
%28 = load i8**, i8*** %3
%29 = call i32 @free(i8** %28)
br label %116
30: ; preds = %21, %76
%31 = phi i8 [ %83, %76 ], [ %23, %21 ]
%32 = phi i8* [ %81, %76 ], [ %14, %21 ]
%33 = phi i64 [ %74, %76 ], [ 0, %21 ]
%34 = phi i32 [ %72, %76 ], [ 0, %21 ]
%35 = phi i32 [ %73, %76 ], [ 0, %21 ]
switch i8 %31, label %51 [
i8 32, label %36
i8 9, label %36
]
36: ; preds = %30, %30
%37 = icmp ne i32 %34, 0
%38 = icmp ne i32 %35, 0
%39 = select i1 %37, i1 true, i1 %38
br i1 %39, label %40, label %45
40: ; preds = %36
%41 = load i32, i32* %6
%42 = add nsw i32 %41, 1
store i32 %42, i32* %6
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds i8, i8* %14, i64 %43
store i8 %31, i8* %44
br label %70
45: ; preds = %36
%46 = call i64 @_popen_noshell_add_token(i8*** %3, i32* %4, i8* %32, i8* %14, i32* %6)
%47 = icmp eq i64 %46, 0
br i1 %47, label %70, label %48
48: ; preds = %45
%49 = load i8**, i8*** %3
%50 = call i32 @free(i8** %49)
br label %116
51: ; preds = %30
%52 = icmp ne i8 %31, 39
%53 = icmp ne i32 %35, 0
%54 = select i1 %52, i1 true, i1 %53
br i1 %54, label %58, label %55
55: ; preds = %51
%56 = icmp eq i32 %34, 0
%57 = zext i1 %56 to i32
br label %70
58: ; preds = %51
%59 = icmp ne i8 %31, 34
%60 = icmp ne i32 %34, 0
%61 = select i1 %59, i1 true, i1 %60
br i1 %61, label %65, label %62
62: ; preds = %58
%63 = xor i1 %53, true
%64 = zext i1 %63 to i32
br label %70
65: ; preds = %58
%66 = load i32, i32* %6
%67 = add nsw i32 %66, 1
store i32 %67, i32* %6
%68 = sext i32 %66 to i64
%69 = getelementptr inbounds i8, i8* %14, i64 %68
store i8 %31, i8* %69
br label %70
70: ; preds = %45, %65, %62, %55, %40
%71 = phi i8* [ %32, %40 ], [ %32, %65 ], [ %32, %62 ], [ %32, %55 ], [ null, %45 ]
%72 = phi i32 [ %34, %40 ], [ %34, %65 ], [ 0, %62 ], [ %57, %55 ], [ 0, %45 ]
%73 = phi i32 [ %35, %40 ], [ %35, %65 ], [ %64, %62 ], [ 0, %55 ], [ 0, %45 ]
%74 = add nuw i64 %33, 1
%75 = icmp eq i64 %74, %22
br i1 %75, label %86, label %76
76: ; preds = %70
%77 = load i32, i32* %6
%78 = icmp eq i8* %71, null
%79 = sext i32 %77 to i64
%80 = getelementptr inbounds i8, i8* %14, i64 %79
%81 = select i1 %78, i8* %80, i8* %71
%82 = getelementptr inbounds i8, i8* %0, i64 %74
%83 = load i8, i8* %82
%84 = call i32* @index(i8* %9, i8 signext %83)
%85 = icmp eq i32* %84, null
br i1 %85, label %30, label %26
86: ; preds = %70, %18
%87 = phi i8* [ null, %18 ], [ %71, %70 ]
%88 = phi i32 [ 0, %18 ], [ %72, %70 ]
%89 = phi i32 [ 0, %18 ], [ %73, %70 ]
%90 = icmp ne i32 %88, 0
%91 = icmp ne i32 %89, 0
%92 = select i1 %90, i1 true, i1 %91
br i1 %92, label %93, label %97
93: ; preds = %86
%94 = load i32, i32* @EINVAL
store i32 %94, i32* @errno
%95 = load i8**, i8*** %3
%96 = call i32 @free(i8** %95)
br label %116
97: ; preds = %86
%98 = call i64 @_popen_noshell_add_token(i8*** %3, i32* %4, i8* %87, i8* %14, i32* %6)
%99 = icmp eq i64 %98, 0
br i1 %99, label %103, label %100
100: ; preds = %97
%101 = load i8**, i8*** %3
%102 = call i32 @free(i8** %101)
br label %116
103: ; preds = %97
%104 = load i32, i32* %4
%105 = icmp eq i32 %104, 0
br i1 %105, label %106, label %110
106: ; preds = %103
%107 = load i32, i32* @EINVAL
store i32 %107, i32* @errno
%108 = load i8**, i8*** %3
%109 = call i32 @free(i8** %108)
br label %116
110: ; preds = %103
%111 = call i64 @popen_noshell_add_ptr_to_argv(i8*** %3, i32* %4, i32* null)
%112 = icmp eq i64 %111, 0
%113 = load i8**, i8*** %3
br i1 %112, label %116, label %114
114: ; preds = %110
%115 = call i32 @free(i8** %113)
br label %116
116: ; preds = %110, %114, %106, %100, %93, %48, %26, %16
%117 = phi i8** [ null, %26 ], [ null, %48 ], [ null, %93 ], [ null, %100 ], [ null, %106 ], [ null, %114 ], [ null, %16 ], [ %113, %110 ]
ret i8** %117
}