#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 */
scalar_t__ _DtHelpCeAddPtrToArray(void **, void *);
char *_DtHelpGetNxtToken(char *, char **);
int ProcessLocations(char *locs, char ***list) {
  char **myList = 0;
  char *nextLoc;
  while (locs != 0 && *locs != '\0') {
    locs = _DtHelpGetNxtToken(locs, &nextLoc);
    if (nextLoc == 0)
      return -1;
    if (*nextLoc != '\0') {
      myList =
          (char **)_DtHelpCeAddPtrToArray((void **)myList, (void *)nextLoc);
      if (myList == 0)
        return -1;
    }
  }
  *list = myList;
  return 0;
}


x86 assembly (clang, -O0):
<ProcessLocations>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x29(%rbp)
je     1158 <ProcessLocations+0x38>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    1168 <ProcessLocations+0x48>
jmp    11d2 <ProcessLocations+0xb2>
mov    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <_DtHelpGetNxtToken@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1190 <ProcessLocations+0x70>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e4 <ProcessLocations+0xc4>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11cd <ProcessLocations+0xad>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <_DtHelpCeAddPtrToArray@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11c8 <ProcessLocations+0xa8>
movl   $0xffffffff,-0x4(%rbp)
jmp    11e4 <ProcessLocations+0xc4>
jmp    11cd <ProcessLocations+0xad>
jmp    1138 <ProcessLocations+0x18>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ProcessLocations>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
xor    %r15d,%r15d
test   %rdi,%rdi
je     1189 <ProcessLocations+0x69>
mov    %rdi,%rbx
xor    %r15d,%r15d
lea    0x8(%rsp),%r12
mov    $0xffffffff,%ebp
jmp    1155 <ProcessLocations+0x35>
nopl   0x0(%rax)
test   %rbx,%rbx
je     1189 <ProcessLocations+0x69>
cmpb   $0x0,(%rbx)
je     1189 <ProcessLocations+0x69>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1040 <_DtHelpGetNxtToken@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     118e <ProcessLocations+0x6e>
mov    %rax,%rbx
cmpb   $0x0,(%rsi)
je     1150 <ProcessLocations+0x30>
mov    %r15,%rdi
call   1030 <_DtHelpCeAddPtrToArray@plt>
mov    %rax,%r15
test   %rax,%rax
jne    1150 <ProcessLocations+0x30>
jmp    118e <ProcessLocations+0x6e>
mov    %r15,(%r14)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @ProcessLocations(i8* %0, i8*** %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8***
%6 = alloca i8**
%7 = alloca i8*
store i8* %0, i8** %4
store i8*** %1, i8**** %5
store i8** null, i8*** %6
br label %8
8: ; preds = %38, %2
%9 = load i8*, i8** %4
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %14, 0
br label %16
16: ; preds = %11, %8
%17 = phi i1 [ false, %8 ], [ %15, %11 ]
br i1 %17, label %18, label %39
18: ; preds = %16
%19 = load i8*, i8** %4
%20 = call i8* @_DtHelpGetNxtToken(i8* %19, i8** %7)
store i8* %20, i8** %4
%21 = load i8*, i8** %7
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 -1, i32* %3
br label %42
24: ; preds = %18
%25 = load i8*, i8** %7
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %38
29: ; preds = %24
%30 = load i8**, i8*** %6
%31 = load i8*, i8** %7
%32 = call i64 @_DtHelpCeAddPtrToArray(i8** %30, i8* %31)
%33 = inttoptr i64 %32 to i8**
store i8** %33, i8*** %6
%34 = load i8**, i8*** %6
%35 = icmp eq i8** %34, null
br i1 %35, label %36, label %37
36: ; preds = %29
store i32 -1, i32* %3
br label %42
37: ; preds = %29
br label %38
38: ; preds = %37, %24
br label %8
39: ; preds = %16
%40 = load i8**, i8*** %6
%41 = load i8***, i8**** %5
store i8** %40, i8*** %41
store i32 0, i32* %3
br label %42
42: ; preds = %39, %36, %23
%43 = load i32, i32* %3
ret i32 %43
}

LLVM IR (-O2):
define i32 @ProcessLocations(i8* %0, i8*** nocapture writeonly %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = icmp eq i8* %0, null
br i1 %5, label %25, label %6
6: ; preds = %2, %22
%7 = phi i8** [ %23, %22 ], [ null, %2 ]
%8 = phi i8* [ %12, %22 ], [ %0, %2 ]
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 0
br i1 %10, label %25, label %11
11: ; preds = %6
%12 = call i8* @_DtHelpGetNxtToken(i8* %8, i8** %3)
%13 = load i8*, i8** %3
%14 = icmp eq i8* %13, null
br i1 %14, label %27, label %15
15: ; preds = %11
%16 = load i8, i8* %13
%17 = icmp eq i8 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = call i64 @_DtHelpCeAddPtrToArray(i8** %7, i8* %13)
%20 = inttoptr i64 %19 to i8**
%21 = icmp eq i64 %19, 0
br i1 %21, label %27, label %22
22: ; preds = %18, %15
%23 = phi i8** [ %20, %18 ], [ %7, %15 ]
%24 = icmp eq i8* %12, null
br i1 %24, label %25, label %6
25: ; preds = %6, %22, %2
%26 = phi i8** [ null, %2 ], [ %23, %22 ], [ %7, %6 ]
store i8** %26, i8*** %1
br label %27
27: ; preds = %18, %11, %25
%28 = phi i32 [ 0, %25 ], [ -1, %11 ], [ -1, %18 ]
ret i32 %28
}