#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__ calloc(int, int);
scalar_t__ piece(char *, char, char *, char);
int /*<<< orphan*/ strdup(char *);
char **pipe_list2list(char *pipe_list, int max_items) {
  char **return_list = (char **)calloc(max_items + 1, sizeof(char *));
  char **return_list_ptr = return_list;
  char buffer[512];
  char i;
  for (i = 0; piece(buffer, '|', pipe_list, i); i++)
    *return_list_ptr++ = strdup(buffer);
  return return_list;
}


x86 assembly (clang, -O0):
<pipe_list2list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
movb   $0x0,-0x221(%rbp)
lea    -0x220(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x7c,%esi
movsbl -0x221(%rbp),%ecx
call   1040 <piece@plt>
cmp    $0x0,%rax
je     11bf <pipe_list2list+0x8f>
lea    -0x220(%rbp),%rdi
call   1050 <strdup@plt>
movslq %eax,%rcx
mov    -0x20(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,(%rax)
mov    -0x221(%rbp),%al
add    $0x1,%al
mov    %al,-0x221(%rbp)
jmp    1165 <pipe_list2list+0x35>
mov    -0x18(%rbp),%rax
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pipe_list2list>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %rdi,%r14
lea    0x1(%rsi),%edi
mov    $0x8,%esi
call   1030 <calloc@plt>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x7c,%esi
mov    %r14,%rdx
xor    %ecx,%ecx
call   1040 <piece@plt>
test   %rax,%rax
je     119a <pipe_list2list+0x6a>
xor    %ebx,%ebx
mov    %rsp,%r12
nopl   (%rax)
mov    %r12,%rdi
call   1050 <strdup@plt>
cltq
mov    %rax,(%r15,%rbx,8)
add    $0x1,%rbx
movsbl %bl,%ecx
mov    %r12,%rdi
mov    $0x7c,%esi
mov    %r14,%rdx
call   1040 <piece@plt>
test   %rax,%rax
jne    1170 <pipe_list2list+0x40>
mov    %r15,%rax
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i8** @pipe_list2list(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8**
%7 = alloca [512 x i8]
%8 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
%9 = load i32, i32* %4
%10 = add nsw i32 %9, 1
%11 = call i64 @calloc(i32 %10, i32 8)
%12 = inttoptr i64 %11 to i8**
store i8** %12, i8*** %5
%13 = load i8**, i8*** %5
store i8** %13, i8*** %6
store i8 0, i8* %8
br label %14
14: ; preds = %27, %2
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%16 = load i8*, i8** %3
%17 = load i8, i8* %8
%18 = call i64 @piece(i8* %15, i8 signext 124, i8* %16, i8 signext %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %14
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%22 = call i32 @strdup(i8* %21)
%23 = sext i32 %22 to i64
%24 = inttoptr i64 %23 to i8*
%25 = load i8**, i8*** %6
%26 = getelementptr inbounds i8*, i8** %25, i32 1
store i8** %26, i8*** %6
store i8* %24, i8** %25
br label %27
27: ; preds = %20
%28 = load i8, i8* %8
%29 = add i8 %28, 1
store i8 %29, i8* %8
br label %14
30: ; preds = %14
%31 = load i8**, i8*** %5
ret i8** %31
}

LLVM IR (-O2):
define i8** @pipe_list2list(i8* %0, i32 %1) {
%3 = alloca [512 x i8]
%4 = add nsw i32 %1, 1
%5 = tail call i64 @calloc(i32 %4, i32 8)
%6 = inttoptr i64 %5 to i8**
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%8 = call i64 @piece(i8* %7, i8 signext 124, i8* %0, i8 signext 0)
%9 = icmp eq i64 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %2, %10
%11 = phi i8 [ %17, %10 ], [ 0, %2 ]
%12 = phi i8** [ %16, %10 ], [ %6, %2 ]
%13 = call i32 @strdup(i8* %7)
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i8*
%16 = getelementptr inbounds i8*, i8** %12, i64 1
store i8* %15, i8** %12
%17 = add i8 %11, 1
%18 = call i64 @piece(i8* %7, i8 signext 124, i8* %0, i8 signext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %10
20: ; preds = %10, %2
ret i8** %6
}