#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 */
struct cmd {
  int dummy;
};

/* Variables and functions */
struct cmd *backcmd(struct cmd *);
int /*<<< orphan*/ gettoken(char **, char *, int /*<<< orphan*/,
                            int /*<<< orphan*/);
struct cmd *listcmd(struct cmd *, struct cmd *);
struct cmd *parsepipe(char **, char *);
scalar_t__ peek(char **, char *, char *);
struct cmd *parseline(char **ps, char *es) {
  struct cmd *cmd;
  cmd = parsepipe(ps, es);
  while (peek(ps, es, "&")) {
    gettoken(ps, es, 0, 0);
    cmd = backcmd(cmd);
  }
  if (peek(ps, es, ";")) {
    gettoken(ps, es, 0, 0);
    cmd = listcmd(cmd, parseline(ps, es));
  }
  return cmd;
}


x86 assembly (clang, -O0):
<parseline>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <parsepipe@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xe70(%rip),%rdx
call   1030 <peek@plt>
cmp    $0x0,%rax
je     11c2 <parseline+0x62>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1040 <gettoken@plt>
mov    -0x18(%rbp),%rdi
call   1080 <backcmd@plt>
mov    %rax,-0x18(%rbp)
jmp    1181 <parseline+0x21>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xe31(%rip),%rdx
call   1030 <peek@plt>
cmp    $0x0,%rax
je     1216 <parseline+0xb6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1040 <gettoken@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <parseline@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rsi
call   1060 <listcmd@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseline>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
call   1070 <parsepipe@plt>
mov    %rax,%rbx
lea    0xe83(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <peek@plt>
test   %rax,%rax
je     11cd <parseline+0x6d>
lea    0xe6c(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <gettoken@plt>
mov    %rbx,%rdi
call   1080 <backcmd@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    %r14,%rsi
mov    %r12,%rdx
call   1030 <peek@plt>
test   %rax,%rax
jne    11a0 <parseline+0x40>
lea    0xe2e(%rip),%rdx
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <peek@plt>
test   %rax,%rax
je     1214 <parseline+0xb4>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <gettoken@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <parseline@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <listcmd@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.cmd = type { i32 }
@.str = [2 x i8] c"&\00"
@.str.1 = [2 x i8] c";\00"
define %struct.cmd* @parseline(i8** %0, i8* %1) {
%3 = alloca i8**
%4 = alloca i8*
%5 = alloca %struct.cmd*
store i8** %0, i8*** %3
store i8* %1, i8** %4
%6 = load i8**, i8*** %3
%7 = load i8*, i8** %4
%8 = call %struct.cmd* @parsepipe(i8** %6, i8* %7)
store %struct.cmd* %8, %struct.cmd** %5
br label %9
9: ; preds = %14, %2
%10 = load i8**, i8*** %3
%11 = load i8*, i8** %4
%12 = call i64 @peek(i8** %10, i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %9
%15 = load i8**, i8*** %3
%16 = load i8*, i8** %4
%17 = call i32 @gettoken(i8** %15, i8* %16, i32 0, i32 0)
%18 = load %struct.cmd*, %struct.cmd** %5
%19 = call %struct.cmd* @backcmd(%struct.cmd* %18)
store %struct.cmd* %19, %struct.cmd** %5
br label %9
20: ; preds = %9
%21 = load i8**, i8*** %3
%22 = load i8*, i8** %4
%23 = call i64 @peek(i8** %21, i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %20
%26 = load i8**, i8*** %3
%27 = load i8*, i8** %4
%28 = call i32 @gettoken(i8** %26, i8* %27, i32 0, i32 0)
%29 = load %struct.cmd*, %struct.cmd** %5
%30 = load i8**, i8*** %3
%31 = load i8*, i8** %4
%32 = call %struct.cmd* @parseline(i8** %30, i8* %31)
%33 = call %struct.cmd* @listcmd(%struct.cmd* %29, %struct.cmd* %32)
store %struct.cmd* %33, %struct.cmd** %5
br label %34
34: ; preds = %25, %20
%35 = load %struct.cmd*, %struct.cmd** %5
ret %struct.cmd* %35
}

LLVM IR (-O2):
%struct.cmd = type { i32 }
@.str = [2 x i8] c"&\00"
@.str.1 = [2 x i8] c";\00"
define %struct.cmd* @parseline(i8** %0, i8* %1) {
%3 = tail call %struct.cmd* @parsepipe(i8** %0, i8* %1)
%4 = tail call i64 @peek(i8** %0, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%5 = icmp eq i64 %4, 0
br i1 %5, label %12, label %6
6: ; preds = %2, %6
%7 = phi %struct.cmd* [ %9, %6 ], [ %3, %2 ]
%8 = tail call i32 @gettoken(i8** %0, i8* %1, i32 0, i32 0)
%9 = tail call %struct.cmd* @backcmd(%struct.cmd* %7)
%10 = tail call i64 @peek(i8** %0, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %12, label %6
12: ; preds = %6, %2
%13 = phi %struct.cmd* [ %3, %2 ], [ %9, %6 ]
%14 = tail call i64 @peek(i8** %0, i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12, %18
%17 = phi %struct.cmd* [ %21, %18 ], [ %13, %12 ]
ret %struct.cmd* %17
18: ; preds = %12
%19 = tail call i32 @gettoken(i8** %0, i8* %1, i32 0, i32 0)
%20 = tail call %struct.cmd* @parseline(i8** %0, i8* %1)
%21 = tail call %struct.cmd* @listcmd(%struct.cmd* %13, %struct.cmd* %20)
br label %16
}