#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*/ free(char *);
int /*<<< orphan*/ strcmp(char *, char *);
char **more_commands(char **current_args) {
  int i = 0;
  if (current_args == NULL)
    return NULL;
  while (current_args[i] != NULL) {
    if (!strcmp(current_args[i], "|")) {
      free(current_args[i]);
      current_args[i] = NULL;
      return (current_args + i + 1);
    }
    i++;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<more_commands>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114b <more_commands+0x2b>
movq   $0x0,-0x8(%rbp)
jmp    11d7 <more_commands+0xb7>
jmp    1150 <more_commands+0x30>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11cf <more_commands+0xaf>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
lea    0xe8a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    11c1 <more_commands+0xa1>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
shl    $0x3,%rcx
add    %rcx,%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
jmp    11d7 <more_commands+0xb7>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <more_commands+0x30>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<more_commands>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
test   %rdi,%rdi
je     116f <more_commands+0x4f>
mov    %rdi,%r15
mov    (%rdi),%r13
xor    %r14d,%r14d
test   %r13,%r13
je     118e <more_commands+0x6e>
lea    0xebd(%rip),%r12
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1174 <more_commands+0x54>
mov    0x8(%r15,%rbx,8),%r13
add    $0x1,%rbx
test   %r13,%r13
jne    1150 <more_commands+0x30>
jmp    118e <more_commands+0x6e>
xor    %r14d,%r14d
jmp    118e <more_commands+0x6e>
mov    %ebx,%ebx
mov    %r13,%rdi
call   1030 <free@plt>
movq   $0x0,(%r15,%rbx,8)
lea    (%r15,%rbx,8),%r14
add    $0x8,%r14
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [2 x i8] c"|\00"
define i8** @more_commands(i8** %0) {
%2 = icmp eq i8** %0, null
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = load i8*, i8** %0
%5 = icmp eq i8* %4, null
br i1 %5, label %21, label %6
6: ; preds = %3, %16
%7 = phi i64 [ %17, %16 ], [ 0, %3 ]
%8 = phi i8* [ %19, %16 ], [ %4, %3 ]
%9 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %16
11: ; preds = %6
%12 = and i64 %7, 4294967295
%13 = getelementptr inbounds i8*, i8** %0, i64 %12
%14 = tail call i32 @free(i8* %8)
store i8* null, i8** %13
%15 = getelementptr inbounds i8*, i8** %13, i64 1
br label %21
16: ; preds = %6
%17 = add nuw i64 %7, 1
%18 = getelementptr inbounds i8*, i8** %0, i64 %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %6
21: ; preds = %16, %3, %1, %11
%22 = phi i8** [ %15, %11 ], [ null, %1 ], [ null, %3 ], [ null, %16 ]
ret i8** %22
}