#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*/ close(int);
int /*<<< orphan*/ dup2(int, int);
int /*<<< orphan*/ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int);
int fork();
int /*<<< orphan*/ pipe(int *);
char *strrchr(char *, char);
int /*<<< orphan*/ *strstr(char *, char *);
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
void for_1pipe(char *ip1, char *ip2, char *envp[]) {
  int pipefd[2];
  int pid1, pid2, stat;
  char *myargv[10];
  if (strstr(ip1, " ") != NULL) {
    char *a1 = {""}, *a2 = {""};
    char *tmp = strrchr(ip1, ' ');
    if (tmp != NULL) {
      *tmp = '\0';
      a1 = tmp + 1;
    }
    a2 = ip1;
    myargv[0] = a2;
    myargv[1] = a1;
    myargv[2] = NULL;
  } else {
    myargv[0] = ip1;
    myargv[1] = NULL;
  }
  char *argv2[10];
  if (strstr(ip2, " ") != NULL) {
    char *a3 = {""}, *a4 = {""};
    char *tmp = strrchr(ip2, ' ');
    if (tmp != NULL) {
      *tmp = '\0';
      a3 = tmp + 1;
    }
    a4 = ip2;
    argv2[0] = a4;
    argv2[1] = a3;
    argv2[2] = NULL;
  } else {
    argv2[0] = ip2;
    argv2[1] = NULL;
  }
  pid1 = fork();
  if (pid1 == 0) {
    pipe(pipefd);
    pid2 = fork();
    if (pid2 == 0) {
      close(1);
      dup2(pipefd[1], 1);
      close(pipefd[0]);
      execve(myargv[0], myargv, envp);
      exit(0);
    } else {
      close(0);
      dup2(pipefd[0], 0);
      close(pipefd[1]);
      execve(argv2[0], argv2, envp);
      exit(1);
    }
  } else {
    waitpid(pid1, &stat, 0);
    return;
  }
}


x86 assembly (clang, -O0):
<for_1pipe>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe4e(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     124a <for_1pipe+0xba>
lea    0xe39(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    0xe2b(%rip),%rax
mov    %rax,-0x90(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x98(%rbp)
cmpq   $0x0,-0x98(%rbp)
je     121c <for_1pipe+0x8c>
mov    -0x98(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x98(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x88(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x88(%rbp),%rax
mov    %rax,-0x78(%rbp)
movq   $0x0,-0x70(%rbp)
jmp    125a <for_1pipe+0xca>
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
movq   $0x0,-0x78(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd9b(%rip),%rsi
call   10b0 <strstr@plt>
cmp    $0x0,%rax
je     1306 <for_1pipe+0x176>
lea    0xd86(%rip),%rax
mov    %rax,-0xf8(%rbp)
lea    0xd78(%rip),%rax
mov    %rax,-0x100(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x20,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x108(%rbp)
cmpq   $0x0,-0x108(%rbp)
je     12cf <for_1pipe+0x13f>
mov    -0x108(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x108(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf8(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x100(%rbp)
mov    -0x100(%rbp),%rax
mov    %rax,-0xf0(%rbp)
mov    -0xf8(%rbp),%rax
mov    %rax,-0xe8(%rbp)
movq   $0x0,-0xe0(%rbp)
jmp    131c <for_1pipe+0x18c>
mov    -0x10(%rbp),%rax
mov    %rax,-0xf0(%rbp)
movq   $0x0,-0xe8(%rbp)
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jne    13be <for_1pipe+0x22e>
lea    -0x20(%rbp),%rdi
call   1060 <pipe@plt>
mov    $0x0,%al
call   10a0 <fork@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    1384 <for_1pipe+0x1f4>
mov    $0x1,%edi
call   1050 <close@plt>
mov    -0x1c(%rbp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    -0x20(%rbp),%edi
call   1050 <close@plt>
mov    -0x80(%rbp),%rdi
lea    -0x80(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <execve@plt>
xor    %edi,%edi
call   1090 <exit@plt>
xor    %edi,%edi
call   1050 <close@plt>
mov    -0x20(%rbp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    -0x1c(%rbp),%edi
call   1050 <close@plt>
mov    -0xf0(%rbp),%rdi
lea    -0xf0(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <execve@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x24(%rbp),%edi
lea    -0x2c(%rbp),%rsi
xor    %edx,%edx
call   1080 <waitpid@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<for_1pipe>:
push   %r15
push   %r14
push   %rbx
sub    $0xb0,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     11cf <for_1pipe+0x3f>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     11df <for_1pipe+0x4f>
movb   $0x0,(%rax)
add    $0x1,%rax
jmp    11e6 <for_1pipe+0x56>
mov    %rbx,0x10(%rsp)
movq   $0x0,0x18(%rsp)
jmp    11f9 <for_1pipe+0x69>
lea    0xe1a(%rip),%rax
mov    %rbx,0x10(%rsp)
mov    %rax,0x18(%rsp)
movq   $0x0,0x20(%rsp)
mov    %r15,%rdi
mov    $0x20,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     1226 <for_1pipe+0x96>
mov    %r15,%rdi
mov    $0x20,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1236 <for_1pipe+0xa6>
movb   $0x0,(%rax)
add    $0x1,%rax
jmp    123d <for_1pipe+0xad>
mov    %r15,0x60(%rsp)
movq   $0x0,0x68(%rsp)
jmp    1250 <for_1pipe+0xc0>
lea    0xdc3(%rip),%rax
mov    %r15,0x60(%rsp)
mov    %rax,0x68(%rsp)
movq   $0x0,0x70(%rsp)
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
je     1276 <for_1pipe+0xe6>
lea    0x8(%rsp),%rsi
mov    %eax,%edi
xor    %edx,%edx
call   1090 <waitpid@plt>
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0x8(%rsp),%rdi
call   1070 <pipe@plt>
xor    %eax,%eax
call   10b0 <fork@plt>
test   %eax,%eax
jne    12c5 <for_1pipe+0x135>
mov    $0x1,%edi
call   1060 <close@plt>
mov    0xc(%rsp),%edi
mov    $0x1,%esi
call   1030 <dup2@plt>
mov    0x8(%rsp),%edi
call   1060 <close@plt>
mov    0x10(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    %r14,%rdx
call   1080 <execve@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
xor    %edi,%edi
call   1060 <close@plt>
mov    0x8(%rsp),%edi
xor    %esi,%esi
call   1030 <dup2@plt>
mov    0xc(%rsp),%edi
call   1060 <close@plt>
lea    0x60(%rsp),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
call   1080 <execve@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [1 x i8] zeroinitializer
define void @for_1pipe(i8* %0, i8* %1, i8** %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca [2 x i32]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [10 x i8*]
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca [10 x i8*]
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8** %2, i8*** %6
%19 = load i8*, i8** %4
%20 = call i32* @strstr(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%21 = icmp ne i32* %20, null
br i1 %21, label %22, label %38
22: ; preds = %3
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %12
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %13
%23 = load i8*, i8** %4
%24 = call i8* @strrchr(i8* %23, i8 signext 32)
store i8* %24, i8** %14
%25 = load i8*, i8** %14
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = load i8*, i8** %14
store i8 0, i8* %28
%29 = load i8*, i8** %14
%30 = getelementptr inbounds i8, i8* %29, i64 1
store i8* %30, i8** %12
br label %31
31: ; preds = %27, %22
%32 = load i8*, i8** %4
store i8* %32, i8** %13
%33 = load i8*, i8** %13
%34 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 0
store i8* %33, i8** %34
%35 = load i8*, i8** %12
%36 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 1
store i8* %35, i8** %36
%37 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 2
store i8* null, i8** %37
br label %42
38: ; preds = %3
%39 = load i8*, i8** %4
%40 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 0
store i8* %39, i8** %40
%41 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 1
store i8* null, i8** %41
br label %42
42: ; preds = %38, %31
%43 = load i8*, i8** %5
%44 = call i32* @strstr(i8* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%45 = icmp ne i32* %44, null
br i1 %45, label %46, label %62
46: ; preds = %42
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %16
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8** %17
%47 = load i8*, i8** %5
%48 = call i8* @strrchr(i8* %47, i8 signext 32)
store i8* %48, i8** %18
%49 = load i8*, i8** %18
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %55
51: ; preds = %46
%52 = load i8*, i8** %18
store i8 0, i8* %52
%53 = load i8*, i8** %18
%54 = getelementptr inbounds i8, i8* %53, i64 1
store i8* %54, i8** %16
br label %55
55: ; preds = %51, %46
%56 = load i8*, i8** %5
store i8* %56, i8** %17
%57 = load i8*, i8** %17
%58 = getelementptr inbounds [10 x i8*], [10 x i8*]* %15, i64 0, i64 0
store i8* %57, i8** %58
%59 = load i8*, i8** %16
%60 = getelementptr inbounds [10 x i8*], [10 x i8*]* %15, i64 0, i64 1
store i8* %59, i8** %60
%61 = getelementptr inbounds [10 x i8*], [10 x i8*]* %15, i64 0, i64 2
store i8* null, i8** %61
br label %66
62: ; preds = %42
%63 = load i8*, i8** %5
%64 = getelementptr inbounds [10 x i8*], [10 x i8*]* %15, i64 0, i64 0
store i8* %63, i8** %64
%65 = getelementptr inbounds [10 x i8*], [10 x i8*]* %15, i64 0, i64 1
store i8* null, i8** %65
br label %66
66: ; preds = %62, %55
%67 = call i32 (...) @fork()
store i32 %67, i32* %8
%68 = load i32, i32* %8
%69 = icmp eq i32 %68, 0
br i1 %69, label %70, label %104
70: ; preds = %66
%71 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%72 = call i32 @pipe(i32* %71)
%73 = call i32 (...) @fork()
store i32 %73, i32* %9
%74 = load i32, i32* %9
%75 = icmp eq i32 %74, 0
br i1 %75, label %76, label %90
76: ; preds = %70
%77 = call i32 @close(i32 1)
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%79 = load i32, i32* %78
%80 = call i32 @dup2(i32 %79, i32 1)
%81 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%82 = load i32, i32* %81
%83 = call i32 @close(i32 %82)
%84 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 0
%85 = load i8*, i8** %84
%86 = getelementptr inbounds [10 x i8*], [10 x i8*]* %11, i64 0, i64 0
%87 = load i8**, i8*** %6
%88 = call i32 @execve(i8* %85, i8** %86, i8** %87)
%89 = call i32 @exit(i32 0)
unreachable
90: ; preds = %70
%91 = call i32 @close(i32 0)
%92 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
%93 = load i32, i32* %92
%94 = call i32 @dup2(i32 %93, i32 0)
%95 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
%96 = load i32, i32* %95
%97 = call i32 @close(i32 %96)
%98 = getelementptr inbounds [10 x i8*], [10 x i8*]* %15, i64 0, i64 0
%99 = load i8*, i8** %98
%100 = getelementptr inbounds [10 x i8*], [10 x i8*]* %15, i64 0, i64 0
%101 = load i8**, i8*** %6
%102 = call i32 @execve(i8* %99, i8** %100, i8** %101)
%103 = call i32 @exit(i32 1)
unreachable
104: ; preds = %66
%105 = load i32, i32* %8
%106 = call i32 @waitpid(i32 %105, i32* %10, i32 0)
ret void
}

LLVM IR (-O2):
@.str.1 = [1 x i8] zeroinitializer
define void @for_1pipe(i8* %0, i8* %1, i8** %2) {
%4 = alloca [2 x i32]
%5 = alloca i32
%6 = alloca [10 x i8*]
%7 = alloca [10 x i8*]
%8 = bitcast [2 x i32]* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast [10 x i8*]* %6 to i8*
%11 = tail call i8* @strchr(i8* dereferenceable(1) %0, i32 32)
%12 = icmp eq i8* %11, null
br i1 %12, label %23, label %13
13: ; preds = %3
%14 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 32)
%15 = icmp eq i8* %14, null
br i1 %15, label %18, label %16
16: ; preds = %13
store i8 0, i8* %14
%17 = getelementptr inbounds i8, i8* %14, i64 1
br label %18
18: ; preds = %16, %13
%19 = phi i8* [ %17, %16 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %13 ]
%20 = getelementptr inbounds [10 x i8*], [10 x i8*]* %6, i64 0, i64 0
store i8* %0, i8** %20
%21 = getelementptr inbounds [10 x i8*], [10 x i8*]* %6, i64 0, i64 1
store i8* %19, i8** %21
%22 = getelementptr inbounds [10 x i8*], [10 x i8*]* %6, i64 0, i64 2
store i8* null, i8** %22
br label %26
23: ; preds = %3
%24 = getelementptr inbounds [10 x i8*], [10 x i8*]* %6, i64 0, i64 0
store i8* %0, i8** %24
%25 = getelementptr inbounds [10 x i8*], [10 x i8*]* %6, i64 0, i64 1
store i8* null, i8** %25
br label %26
26: ; preds = %23, %18
%27 = bitcast [10 x i8*]* %7 to i8*
%28 = tail call i8* @strchr(i8* dereferenceable(1) %1, i32 32)
%29 = icmp eq i8* %28, null
br i1 %29, label %40, label %30
30: ; preds = %26
%31 = tail call i8* @strrchr(i8* dereferenceable(1) %1, i8 signext 32)
%32 = icmp eq i8* %31, null
br i1 %32, label %35, label %33
33: ; preds = %30
store i8 0, i8* %31
%34 = getelementptr inbounds i8, i8* %31, i64 1
br label %35
35: ; preds = %33, %30
%36 = phi i8* [ %34, %33 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %30 ]
%37 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
store i8* %1, i8** %37
%38 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 1
store i8* %36, i8** %38
%39 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 2
store i8* null, i8** %39
br label %43
40: ; preds = %26
%41 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
store i8* %1, i8** %41
%42 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 1
store i8* null, i8** %42
br label %43
43: ; preds = %40, %35
%44 = tail call i32 (...) @fork()
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %72
46: ; preds = %43
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 0
%48 = call i32 @pipe(i32* %47)
%49 = call i32 (...) @fork()
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %62
51: ; preds = %46
%52 = call i32 @close(i32 1)
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%54 = load i32, i32* %53
%55 = call i32 @dup2(i32 %54, i32 1)
%56 = load i32, i32* %47
%57 = call i32 @close(i32 %56)
%58 = getelementptr inbounds [10 x i8*], [10 x i8*]* %6, i64 0, i64 0
%59 = load i8*, i8** %58
%60 = call i32 @execve(i8* %59, i8** %58, i8** %2)
%61 = call i32 @exit(i32 0)
unreachable
62: ; preds = %46
%63 = call i32 @close(i32 0)
%64 = load i32, i32* %47
%65 = call i32 @dup2(i32 %64, i32 0)
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %4, i64 0, i64 1
%67 = load i32, i32* %66
%68 = call i32 @close(i32 %67)
%69 = getelementptr inbounds [10 x i8*], [10 x i8*]* %7, i64 0, i64 0
%70 = call i32 @execve(i8* %1, i8** %69, i8** %2)
%71 = call i32 @exit(i32 1)
unreachable
72: ; preds = %43
%73 = call i32 @waitpid(i32 %44, i32* %5, i32 0)
ret void
}