#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*/ *gets(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
void *strtok(char *, char *);
int prompt_and_parse(char **u, char **d) {
  static char line[100];
  d[0] = NULL;
  printf("> ");
  if (gets(line) == NULL)
    return -1;
  *u++ = strtok(line, " \t");
  while (*u = strtok(NULL, " \t")) {
    if (strcmp(*u, "|") == 0) {
      *u = NULL;
      while (*d++ = strtok(NULL, " \t"))
        ;
      return 1;
    }
    u++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<prompt_and_parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
lea    0xe9e(%rip),%rdi
call   1030 <printf@plt>
lea    0x2ee2(%rip),%rdi
call   1050 <gets@plt>
cmp    $0x0,%rax
jne    1189 <prompt_and_parse+0x49>
movl   $0xffffffff,-0x4(%rbp)
jmp    124f <prompt_and_parse+0x10f>
lea    0x2ec0(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe47(%rip),%rsi
call   1060 <strtok@plt>
mov    -0x10(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
je     1248 <prompt_and_parse+0x108>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xe26(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1237 <prompt_and_parse+0xf7>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdfe(%rip),%rsi
call   1060 <strtok@plt>
mov    -0x18(%rbp),%rcx
mov    %rcx,%rdx
add    $0x8,%rdx
mov    %rdx,-0x18(%rbp)
mov    %rax,(%rcx)
cmp    $0x0,%rax
je     122b <prompt_and_parse+0xeb>
jmp    11fa <prompt_and_parse+0xba>
movl   $0x1,-0x4(%rbp)
jmp    124f <prompt_and_parse+0x10f>
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11b1 <prompt_and_parse+0x71>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prompt_and_parse>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
movq   $0x0,(%rsi)
lea    0xea4(%rip),%rdi
call   1030 <printf@plt>
lea    0x2ee8(%rip),%rdi
call   1050 <gets@plt>
test   %rax,%rax
je     11f8 <prompt_and_parse+0xb8>
lea    0x2ed3(%rip),%rdi
lea    0xe7f(%rip),%r15
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,(%rbx)
add    $0x8,%rbx
lea    0xe6c(%rip),%r12
mov    $0x1,%ebp
nop
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     11fd <prompt_and_parse+0xbd>
mov    %rax,%rdi
mov    %r12,%rsi
call   1040 <strcmp@plt>
add    $0x8,%rbx
test   %rax,%rax
jne    11a0 <prompt_and_parse+0x60>
movq   $0x0,-0x8(%rbx)
lea    0xe2e(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
mov    %rax,(%r14)
add    $0x8,%r14
test   %rax,%rax
jne    11e0 <prompt_and_parse+0xa0>
jmp    11fd <prompt_and_parse+0xbd>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@prompt_and_parse.line = internal global [100 x i8] zeroinitializer
@.str = [3 x i8] c"> \00"
@.str.1 = [3 x i8] c" \09\00"
@.str.2 = [2 x i8] c"|\00"
define i32 @prompt_and_parse(i8** %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8**
store i8** %0, i8*** %4
store i8** %1, i8*** %5
%6 = load i8**, i8*** %5
%7 = getelementptr inbounds i8*, i8** %6, i64 0
store i8* null, i8** %7
%8 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = call i32* @gets(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @prompt_and_parse.line, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 -1, i32* %3
br label %38
12: ; preds = %2
%13 = call i8* @strtok(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @prompt_and_parse.line, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i32 1
store i8** %15, i8*** %4
store i8* %13, i8** %14
br label %16
16: ; preds = %34, %12
%17 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%18 = load i8**, i8*** %4
store i8* %17, i8** %18
%19 = icmp ne i8* %17, null
br i1 %19, label %20, label %37
20: ; preds = %16
%21 = load i8**, i8*** %4
%22 = load i8*, i8** %21
%23 = call i64 @strcmp(i8* %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %20
%26 = load i8**, i8*** %4
store i8* null, i8** %26
br label %27
27: ; preds = %32, %25
%28 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i32 1
store i8** %30, i8*** %5
store i8* %28, i8** %29
%31 = icmp ne i8* %28, null
br i1 %31, label %32, label %33
32: ; preds = %27
br label %27
33: ; preds = %27
store i32 1, i32* %3
br label %38
34: ; preds = %20
%35 = load i8**, i8*** %4
%36 = getelementptr inbounds i8*, i8** %35, i32 1
store i8** %36, i8*** %4
br label %16
37: ; preds = %16
store i32 1, i32* %3
br label %38
38: ; preds = %37, %33, %11
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@prompt_and_parse.line = internal global [100 x i8] zeroinitializer
@.str = [3 x i8] c"> \00"
@.str.1 = [3 x i8] c" \09\00"
@.str.2 = [2 x i8] c"|\00"
define i32 @prompt_and_parse(i8** nocapture writeonly %0, i8** nocapture writeonly %1) {
store i8* null, i8** %1
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%4 = tail call i32* @gets(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @prompt_and_parse.line, i64 0, i64 0))
%5 = icmp eq i32* %4, null
br i1 %5, label %22, label %6
6: ; preds = %2
%7 = tail call i8* @strtok(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @prompt_and_parse.line, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %7, i8** %0
br label %8
8: ; preds = %13, %6
%9 = phi i8** [ %0, %6 ], [ %10, %13 ]
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i8* %11, i8** %10
%12 = icmp eq i8* %11, null
br i1 %12, label %22, label %13
13: ; preds = %8
%14 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %8
16: ; preds = %13
store i8* null, i8** %10
br label %17
17: ; preds = %17, %16
%18 = phi i8** [ %1, %16 ], [ %20, %17 ]
%19 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = getelementptr inbounds i8*, i8** %18, i64 1
store i8* %19, i8** %18
%21 = icmp eq i8* %19, null
br i1 %21, label %22, label %17
22: ; preds = %8, %17, %2
%23 = phi i32 [ -1, %2 ], [ 1, %17 ], [ 1, %8 ]
ret i32 %23
}