#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*/ bzero(char *, int);
int /*<<< orphan*/ direxist(int, char *);
int /*<<< orphan*/ ls(int, char *);
int /*<<< orphan*/ pull(int, char *);
int /*<<< orphan*/ push(int, char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int strnlen(char *, int);
int parse(int sock, char *message) {
  char command[6];
  char arg[250];
  bzero(command, 6);
  bzero(arg, 250);
  int i = 0;
  int j = 0;
  for (; ((message[i] != ' ') && (i < strnlen(message, 256))); i++)
    command[i] = message[i];
  i++;
  for (; i < strnlen(message, 256); i++)
    arg[j++] = message[i];
  if (!(strncmp(command, "cd", 2)))
    direxist(sock, arg);
  if (!(strncmp(command, "ls", 2)))
    ls(sock, arg);
  if (!(strncmp(command, "pull", 4)))
    pull(sock, arg);
  if (!(strncmp(command, "push", 4)))
    push(sock, arg);
  if (!(strncmp(command, "exit", 4)))
    return 2;
  return 1;
}


x86 assembly (clang, -O0):
<parse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x16(%rbp),%rdi
mov    $0x6,%esi
call   1090 <bzero@plt>
lea    -0x110(%rbp),%rdi
mov    $0xfa,%esi
call   1090 <bzero@plt>
movl   $0x0,-0x114(%rbp)
movl   $0x0,-0x118(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x114(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x119(%rbp)
je     1202 <parse+0x92>
mov    -0x114(%rbp),%eax
mov    %eax,-0x120(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x100,%esi
call   1050 <strnlen@plt>
mov    %eax,%ecx
mov    -0x120(%rbp),%eax
cmp    %ecx,%eax
setl   %al
mov    %al,-0x119(%rbp)
mov    -0x119(%rbp),%al
test   $0x1,%al
jne    1215 <parse+0xa5>
jmp    1242 <parse+0xd2>
mov    -0x10(%rbp),%rax
movslq -0x114(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x114(%rbp),%rax
mov    %cl,-0x16(%rbp,%rax,1)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    11b5 <parse+0x45>
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
mov    -0x114(%rbp),%eax
mov    %eax,-0x124(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x100,%esi
call   1050 <strnlen@plt>
mov    %eax,%ecx
mov    -0x124(%rbp),%eax
cmp    %ecx,%eax
jge    12b7 <parse+0x147>
mov    -0x10(%rbp),%rax
movslq -0x114(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x118(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x118(%rbp)
cltq
mov    %cl,-0x110(%rbp,%rax,1)
mov    -0x114(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x114(%rbp)
jmp    1251 <parse+0xe1>
lea    -0x16(%rbp),%rdi
lea    0xd3e(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    12e4 <parse+0x174>
mov    -0x8(%rbp),%edi
lea    -0x110(%rbp),%rsi
call   1070 <direxist@plt>
lea    -0x16(%rbp),%rdi
lea    0xd14(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1311 <parse+0x1a1>
mov    -0x8(%rbp),%edi
lea    -0x110(%rbp),%rsi
call   1060 <ls@plt>
lea    -0x16(%rbp),%rdi
lea    0xcea(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    133e <parse+0x1ce>
mov    -0x8(%rbp),%edi
lea    -0x110(%rbp),%rsi
call   1040 <pull@plt>
lea    -0x16(%rbp),%rdi
lea    0xcc2(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    136b <parse+0x1fb>
mov    -0x8(%rbp),%edi
lea    -0x110(%rbp),%rsi
call   1080 <push@plt>
lea    -0x16(%rbp),%rdi
lea    0xc9a(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1395 <parse+0x225>
movl   $0x2,-0x4(%rbp)
jmp    139c <parse+0x22c>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %rsi,%r15
mov    %edi,%r14d
lea    0xa(%rsp),%rdi
mov    $0x6,%esi
call   1090 <bzero@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0xfa,%esi
call   1090 <bzero@plt>
xor    %r12d,%r12d
cmpb   $0x20,(%r15)
je     11f1 <parse+0x81>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x100,%esi
call   1050 <strnlen@plt>
cltq
cmp    %rax,%rbx
jge    11ee <parse+0x7e>
movzbl (%r15,%rbx,1),%eax
mov    %al,0xa(%rsp,%rbx,1)
lea    0x1(%rbx),%r12
cmpb   $0x20,0x1(%r15,%rbx,1)
mov    %r12,%rbx
jne    11c0 <parse+0x50>
jmp    11f1 <parse+0x81>
mov    %rbx,%r12
lea    0x1(%r12),%ebx
mov    %r15,%rdi
mov    $0x100,%esi
call   1050 <strnlen@plt>
cmp    %eax,%ebx
jge    1231 <parse+0xc1>
mov    %r12d,%ebx
add    $0x1,%rbx
xchg   %ax,%ax
movzbl (%r15,%rbx,1),%eax
mov    %al,0x0(%rbp)
add    $0x1,%rbx
mov    %r15,%rdi
mov    $0x100,%esi
call   1050 <strnlen@plt>
add    $0x1,%rbp
cmp    %ebx,%eax
jg     1210 <parse+0xa0>
lea    0xdc8(%rip),%rsi
lea    0xa(%rsp),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    1258 <parse+0xe8>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
call   1070 <direxist@plt>
lea    0xda4(%rip),%rsi
lea    0xa(%rsp),%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    127f <parse+0x10f>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
call   1060 <ls@plt>
lea    0xd80(%rip),%rsi
lea    0xa(%rsp),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    12a6 <parse+0x136>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
call   1040 <pull@plt>
lea    0xd5e(%rip),%rsi
lea    0xa(%rsp),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    12cd <parse+0x15d>
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
call   1080 <push@plt>
lea    0xd3c(%rip),%rsi
lea    0xa(%rsp),%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x1,%eax
mov    $0x1,%eax
adc    $0x0,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"cd\00"
@.str.1 = [3 x i8] c"ls\00"
@.str.2 = [5 x i8] c"pull\00"
@.str.3 = [5 x i8] c"push\00"
@.str.4 = [5 x i8] c"exit\00"
define i32 @parse(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [6 x i8]
%7 = alloca [250 x i8]
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%11 = call i32 @bzero(i8* %10, i32 6)
%12 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%13 = call i32 @bzero(i8* %12, i32 250)
store i32 0, i32* %8
store i32 0, i32* %9
br label %14
14: ; preds = %38, %2
%15 = load i8*, i8** %5
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 32
br i1 %21, label %22, label %27
22: ; preds = %14
%23 = load i32, i32* %8
%24 = load i8*, i8** %5
%25 = call i32 @strnlen(i8* %24, i32 256)
%26 = icmp slt i32 %23, %25
br label %27
27: ; preds = %22, %14
%28 = phi i1 [ false, %14 ], [ %26, %22 ]
br i1 %28, label %29, label %41
29: ; preds = %27
%30 = load i8*, i8** %5
%31 = load i32, i32* %8
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = load i32, i32* %8
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %36
store i8 %34, i8* %37
br label %38
38: ; preds = %29
%39 = load i32, i32* %8
%40 = add nsw i32 %39, 1
store i32 %40, i32* %8
br label %14
41: ; preds = %27
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %44
44: ; preds = %59, %41
%45 = load i32, i32* %8
%46 = load i8*, i8** %5
%47 = call i32 @strnlen(i8* %46, i32 256)
%48 = icmp slt i32 %45, %47
br i1 %48, label %49, label %62
49: ; preds = %44
%50 = load i8*, i8** %5
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
store i32 %56, i32* %9
%57 = sext i32 %55 to i64
%58 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 %57
store i8 %54, i8* %58
br label %59
59: ; preds = %49
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %44
62: ; preds = %44
%63 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%64 = call i32 @strncmp(i8* %63, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%65 = icmp ne i32 %64, 0
br i1 %65, label %70, label %66
66: ; preds = %62
%67 = load i32, i32* %4
%68 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%69 = call i32 @direxist(i32 %67, i8* %68)
br label %70
70: ; preds = %66, %62
%71 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%72 = call i32 @strncmp(i8* %71, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%73 = icmp ne i32 %72, 0
br i1 %73, label %78, label %74
74: ; preds = %70
%75 = load i32, i32* %4
%76 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%77 = call i32 @ls(i32 %75, i8* %76)
br label %78
78: ; preds = %74, %70
%79 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%80 = call i32 @strncmp(i8* %79, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%81 = icmp ne i32 %80, 0
br i1 %81, label %86, label %82
82: ; preds = %78
%83 = load i32, i32* %4
%84 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%85 = call i32 @pull(i32 %83, i8* %84)
br label %86
86: ; preds = %82, %78
%87 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%88 = call i32 @strncmp(i8* %87, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%89 = icmp ne i32 %88, 0
br i1 %89, label %94, label %90
90: ; preds = %86
%91 = load i32, i32* %4
%92 = getelementptr inbounds [250 x i8], [250 x i8]* %7, i64 0, i64 0
%93 = call i32 @push(i32 %91, i8* %92)
br label %94
94: ; preds = %90, %86
%95 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%96 = call i32 @strncmp(i8* %95, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%97 = icmp ne i32 %96, 0
br i1 %97, label %99, label %98
98: ; preds = %94
store i32 2, i32* %3
br label %100
99: ; preds = %94
store i32 1, i32* %3
br label %100
100: ; preds = %99, %98
%101 = load i32, i32* %3
ret i32 %101
}

LLVM IR (-O2):
@.str = [3 x i8] c"cd\00"
@.str.1 = [3 x i8] c"ls\00"
@.str.2 = [5 x i8] c"pull\00"
@.str.3 = [5 x i8] c"push\00"
@.str.4 = [5 x i8] c"exit\00"
define i32 @parse(i32 %0, i8* %1) {
%3 = alloca [6 x i8]
%4 = alloca [250 x i8]
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [250 x i8], [250 x i8]* %4, i64 0, i64 0
%7 = call i32 @bzero(i8* %5, i32 6)
%8 = call i32 @bzero(i8* %6, i32 250)
%9 = load i8, i8* %1
%10 = icmp eq i8 %9, 32
br i1 %10, label %27, label %11
11: ; preds = %2, %17
%12 = phi i64 [ %20, %17 ], [ 0, %2 ]
%13 = phi i8* [ %21, %17 ], [ %1, %2 ]
%14 = tail call i32 @strnlen(i8* %1, i32 256)
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %12, %15
br i1 %16, label %17, label %24
17: ; preds = %11
%18 = load i8, i8* %13
%19 = getelementptr inbounds [6 x i8], [6 x i8]* %3, i64 0, i64 %12
store i8 %18, i8* %19
%20 = add nuw nsw i64 %12, 1
%21 = getelementptr inbounds i8, i8* %1, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 32
br i1 %23, label %24, label %11
24: ; preds = %17, %11
%25 = phi i64 [ %12, %11 ], [ %20, %17 ]
%26 = trunc i64 %25 to i32
br label %27
27: ; preds = %24, %2
%28 = phi i32 [ 0, %2 ], [ %26, %24 ]
%29 = add nuw nsw i32 %28, 1
%30 = tail call i32 @strnlen(i8* %1, i32 256)
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %46
32: ; preds = %27
%33 = zext i32 %28 to i64
%34 = add nuw nsw i64 %33, 1
br label %35
35: ; preds = %32, %35
%36 = phi i64 [ 0, %32 ], [ %40, %35 ]
%37 = phi i64 [ %34, %32 ], [ %42, %35 ]
%38 = getelementptr inbounds i8, i8* %1, i64 %37
%39 = load i8, i8* %38
%40 = add nuw nsw i64 %36, 1
%41 = getelementptr inbounds [250 x i8], [250 x i8]* %4, i64 0, i64 %36
store i8 %39, i8* %41
%42 = add nuw nsw i64 %37, 1
%43 = tail call i32 @strnlen(i8* %1, i32 256)
%44 = trunc i64 %42 to i32
%45 = icmp sgt i32 %43, %44
br i1 %45, label %35, label %46
46: ; preds = %35, %27
%47 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %51
49: ; preds = %46
%50 = call i32 @direxist(i32 %0, i8* %6)
br label %51
51: ; preds = %49, %46
%52 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 @ls(i32 %0, i8* %6)
br label %56
56: ; preds = %54, %51
%57 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 4)
%58 = icmp eq i32 %57, 0
br i1 %58, label %59, label %61
59: ; preds = %56
%60 = call i32 @pull(i32 %0, i8* %6)
br label %61
61: ; preds = %59, %56
%62 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 4)
%63 = icmp eq i32 %62, 0
br i1 %63, label %64, label %66
64: ; preds = %61
%65 = call i32 @push(i32 %0, i8* %6)
br label %66
66: ; preds = %64, %61
%67 = call i32 @strncmp(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 4)
%68 = icmp eq i32 %67, 0
%69 = select i1 %68, i32 2, i32 1
ret i32 %69
}