#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char **);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int parser() {
  char *input;
  char list[10] = "LIST";
  char diff[10] = "DIFF";
  char pull[10] = "PULL";
  char leave[10] = "LEAVE";
  int givenMethod = -1;
  while (givenMethod == -1) {
    printf("Enter LIST, DIFF, PULL, or LEAVE (In all CAPS):");
    scanf("%as", &input);
    if (strlen(input) < 10 && strncmp(input, "LIST", 10) == 0)
      givenMethod = 0;
    else if (strlen(input) < 10 && strncmp(input, "DIFF", 10) == 0)
      givenMethod = 1;
    else if (strlen(input) < 10 && strncmp(input, "PULL", 10) == 0)
      givenMethod = 2;
    else if (strlen(input) < 10 && strncmp(input, "LEAVE", 10) == 0)
      givenMethod = 3;
    else if (strlen(input) < 10 && strncmp(input, "CAP", 10) == 0)
      givenMethod = 4;
    else
      printf("Invalid input\n");
  }
  return givenMethod;
}


x86 assembly (clang, -O0):
<parser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x12(%rbp)
mov    0xeae(%rip),%ax
mov    %ax,-0xa(%rbp)
mov    0xea5(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xea2(%rip),%ax
mov    %ax,-0x14(%rbp)
mov    0xe99(%rip),%rax
mov    %rax,-0x26(%rbp)
mov    0xe96(%rip),%ax
mov    %ax,-0x1e(%rbp)
mov    0xe8d(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe8a(%rip),%ax
mov    %ax,-0x28(%rbp)
movl   $0xffffffff,-0x34(%rbp)
cmpl   $0xffffffff,-0x34(%rbp)
jne    1323 <parser+0x1e3>
lea    0xe70(%rip),%rdi
call   1050 <printf@plt>
lea    0xe94(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xa,%eax
jge    120a <parser+0xca>
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    120a <parser+0xca>
movl   $0x0,-0x34(%rbp)
jmp    131e <parser+0x1de>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xa,%eax
jge    1247 <parser+0x107>
mov    -0x8(%rbp),%rdi
lea    0xe3a(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1247 <parser+0x107>
movl   $0x1,-0x34(%rbp)
jmp    1319 <parser+0x1d9>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xa,%eax
jge    1284 <parser+0x144>
mov    -0x8(%rbp),%rdi
lea    0xe02(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1284 <parser+0x144>
movl   $0x2,-0x34(%rbp)
jmp    1314 <parser+0x1d4>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xa,%eax
jge    12c1 <parser+0x181>
mov    -0x8(%rbp),%rdi
lea    0xdca(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12c1 <parser+0x181>
movl   $0x3,-0x34(%rbp)
jmp    130f <parser+0x1cf>
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0xa,%eax
jge    12fe <parser+0x1be>
mov    -0x8(%rbp),%rdi
lea    0xd93(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12fe <parser+0x1be>
movl   $0x4,-0x34(%rbp)
jmp    130a <parser+0x1ca>
lea    0xd70(%rip),%rdi
call   1050 <printf@plt>
jmp    130f <parser+0x1cf>
jmp    1314 <parser+0x1d4>
jmp    1319 <parser+0x1d9>
jmp    131e <parser+0x1de>
jmp    11a7 <parser+0x67>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parser>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe9e(%rip),%r14
lea    0xec7(%rip),%r15
mov    %rsp,%rbx
lea    0xec1(%rip),%r12
lea    0xebf(%rip),%r13
lea    0xecc(%rip),%rbp
jmp    1198 <parser+0x48>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    (%rsp),%rdi
call   1050 <strlen@plt>
cmp    $0x9,%eax
jg     11d3 <parser+0x83>
mov    (%rsp),%rdi
mov    %r12,%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1282 <parser+0x132>
mov    (%rsp),%rdi
call   1050 <strlen@plt>
cmp    $0x9,%eax
jg     11fb <parser+0xab>
mov    (%rsp),%rdi
mov    %r13,%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1286 <parser+0x136>
mov    (%rsp),%rdi
call   1050 <strlen@plt>
cmp    $0x9,%eax
jg     1223 <parser+0xd3>
mov    (%rsp),%rdi
lea    0xe2a(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     128d <parser+0x13d>
mov    (%rsp),%rdi
call   1050 <strlen@plt>
cmp    $0x9,%eax
jg     124b <parser+0xfb>
mov    (%rsp),%rdi
lea    0xe07(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1294 <parser+0x144>
mov    (%rsp),%rdi
call   1050 <strlen@plt>
cmp    $0x9,%eax
jg     1190 <parser+0x40>
mov    (%rsp),%rdi
lea    0xde1(%rip),%rsi
mov    $0xa,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1190 <parser+0x40>
mov    $0x4,%eax
jmp    1299 <parser+0x149>
xor    %eax,%eax
jmp    1299 <parser+0x149>
mov    $0x1,%eax
jmp    1299 <parser+0x149>
mov    $0x2,%eax
jmp    1299 <parser+0x149>
mov    $0x3,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.parser.list = [10 x i8] c"LIST\00\00\00\00\00\00"
@__const.parser.diff = [10 x i8] c"DIFF\00\00\00\00\00\00"
@__const.parser.pull = [10 x i8] c"PULL\00\00\00\00\00\00"
@__const.parser.leave = [10 x i8] c"LEAVE\00\00\00\00\00"
@.str = [48 x i8] c"Enter LIST, DIFF, PULL, or LEAVE (In all CAPS):\00"
@.str.1 = [4 x i8] c"%as\00"
@.str.2 = [5 x i8] c"LIST\00"
@.str.3 = [5 x i8] c"DIFF\00"
@.str.4 = [5 x i8] c"PULL\00"
@.str.5 = [6 x i8] c"LEAVE\00"
@.str.6 = [4 x i8] c"CAP\00"
@.str.7 = [15 x i8] c"Invalid input\0A\00"
define i32 @parser() {
%1 = alloca i8*
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = alloca [10 x i8]
%5 = alloca [10 x i8]
%6 = alloca i32
%7 = bitcast [10 x i8]* %2 to i8*
%8 = bitcast [10 x i8]* %3 to i8*
%9 = bitcast [10 x i8]* %4 to i8*
%10 = bitcast [10 x i8]* %5 to i8*
store i32 -1, i32* %6
br label %11
11: ; preds = %67, %0
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %68
14: ; preds = %11
%15 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %1)
%17 = load i8*, i8** %1
%18 = call i32 @strlen(i8* %17)
%19 = icmp slt i32 %18, 10
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i8*, i8** %1
%22 = call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 10)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 0, i32* %6
br label %67
25: ; preds = %20, %14
%26 = load i8*, i8** %1
%27 = call i32 @strlen(i8* %26)
%28 = icmp slt i32 %27, 10
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load i8*, i8** %1
%31 = call i64 @strncmp(i8* %30, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 10)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %29
store i32 1, i32* %6
br label %66
34: ; preds = %29, %25
%35 = load i8*, i8** %1
%36 = call i32 @strlen(i8* %35)
%37 = icmp slt i32 %36, 10
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i8*, i8** %1
%40 = call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 10)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %38
store i32 2, i32* %6
br label %65
43: ; preds = %38, %34
%44 = load i8*, i8** %1
%45 = call i32 @strlen(i8* %44)
%46 = icmp slt i32 %45, 10
br i1 %46, label %47, label %52
47: ; preds = %43
%48 = load i8*, i8** %1
%49 = call i64 @strncmp(i8* %48, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 10)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %52
51: ; preds = %47
store i32 3, i32* %6
br label %64
52: ; preds = %47, %43
%53 = load i8*, i8** %1
%54 = call i32 @strlen(i8* %53)
%55 = icmp slt i32 %54, 10
br i1 %55, label %56, label %61
56: ; preds = %52
%57 = load i8*, i8** %1
%58 = call i64 @strncmp(i8* %57, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 10)
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %61
60: ; preds = %56
store i32 4, i32* %6
br label %63
61: ; preds = %56, %52
%62 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
br label %63
63: ; preds = %61, %60
br label %64
64: ; preds = %63, %51
br label %65
65: ; preds = %64, %42
br label %66
66: ; preds = %65, %33
br label %67
67: ; preds = %66, %24
br label %11
68: ; preds = %11
%69 = load i32, i32* %6
ret i32 %69
}

LLVM IR (-O2):
@.str = [48 x i8] c"Enter LIST, DIFF, PULL, or LEAVE (In all CAPS):\00"
@.str.1 = [4 x i8] c"%as\00"
@.str.2 = [5 x i8] c"LIST\00"
@.str.3 = [5 x i8] c"DIFF\00"
@.str.4 = [5 x i8] c"PULL\00"
@.str.5 = [6 x i8] c"LEAVE\00"
@.str.6 = [4 x i8] c"CAP\00"
@str = [14 x i8] c"Invalid input\00"
define i32 @parser() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
br label %3
3: ; preds = %45, %0
%4 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %1)
%6 = load i8*, i8** %1
%7 = call i32 @strlen(i8* %6)
%8 = icmp slt i32 %7, 10
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load i8*, i8** %1
%11 = call i64 @strncmp(i8* %10, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 10)
%12 = icmp eq i64 %11, 0
br i1 %12, label %47, label %13
13: ; preds = %9, %3
%14 = load i8*, i8** %1
%15 = call i32 @strlen(i8* %14)
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i8*, i8** %1
%19 = call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 10)
%20 = icmp eq i64 %19, 0
br i1 %20, label %47, label %21
21: ; preds = %17, %13
%22 = load i8*, i8** %1
%23 = call i32 @strlen(i8* %22)
%24 = icmp slt i32 %23, 10
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i8*, i8** %1
%27 = call i64 @strncmp(i8* %26, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 10)
%28 = icmp eq i64 %27, 0
br i1 %28, label %47, label %29
29: ; preds = %25, %21
%30 = load i8*, i8** %1
%31 = call i32 @strlen(i8* %30)
%32 = icmp slt i32 %31, 10
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i8*, i8** %1
%35 = call i64 @strncmp(i8* %34, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i32 10)
%36 = icmp eq i64 %35, 0
br i1 %36, label %47, label %37
37: ; preds = %33, %29
%38 = load i8*, i8** %1
%39 = call i32 @strlen(i8* %38)
%40 = icmp slt i32 %39, 10
br i1 %40, label %41, label %45
41: ; preds = %37
%42 = load i8*, i8** %1
%43 = call i64 @strncmp(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 10)
%44 = icmp eq i64 %43, 0
br i1 %44, label %47, label %45
45: ; preds = %37, %41
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %3
47: ; preds = %41, %33, %25, %17, %9
%48 = phi i32 [ 0, %9 ], [ 1, %17 ], [ 2, %25 ], [ 3, %33 ], [ 4, %41 ]
ret i32 %48
}