#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 */
typedef int /*<<< orphan*/ inp;

/* Variables and functions */
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
scalar_t__ isspace(char const);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stdin;
void handle_CLI(void (*single_char_CLI)(const char *c),
                void (*single_char_CLI_with_num)(const char *c),
                void (*multi_char_CLI)(const char *c)) {
  int exit_condition = 0;
  char inp[200];
  do {
    if (!exit_condition)
      printf("Command>");
    const char *s;
    if (fgets(inp, sizeof(inp), stdin) == NULL) {
      printf("Input error, exiting\n");
      break;
    }
    for (s = inp; (*s != '\n') && isspace(*s); s++)
      ;
    if (*s == '\n') {
      printf("Blank Line entered, sure you want to quit [y|n]:");
      exit_condition = 1;
    } else {
      if (*(s + 1) == '\n') {
        if (exit_condition) {
          if (*s == 'y' || *s == 'Y')
            break;
          else if (*s == 'n' || *s == 'N')
            exit_condition = 0;
        } else if (single_char_CLI)
          single_char_CLI(s);
      } else if (*(s + 1) >= '0' && *(s + 1) <= '9') {
        if (single_char_CLI_with_num)
          single_char_CLI_with_num(s);
      } else if (multi_char_CLI) {
        multi_char_CLI(s);
      }
    }
  } while (1);
}


x86 assembly (clang, -O0):
<handle_CLI>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1164 <handle_CLI+0x34>
lea    0xea1(%rip),%rdi
call   1030 <printf@plt>
lea    -0xf0(%rbp),%rdi
mov    0x2e76(%rip),%rax
mov    (%rax),%edx
mov    $0xc8,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jne    1199 <handle_CLI+0x69>
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
jmp    135a <handle_CLI+0x22a>
lea    -0xf0(%rbp),%rax
mov    %rax,-0xf8(%rbp)
mov    -0xf8(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0xf9(%rbp)
je     11de <handle_CLI+0xae>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isspace@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0xf9(%rbp)
mov    -0xf9(%rbp),%al
test   $0x1,%al
jne    11f1 <handle_CLI+0xc1>
jmp    120d <handle_CLI+0xdd>
jmp    11f6 <handle_CLI+0xc6>
mov    -0xf8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0xf8(%rbp)
jmp    11a7 <handle_CLI+0x77>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1238 <handle_CLI+0x108>
lea    0xdf8(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x1c(%rbp)
jmp    1346 <handle_CLI+0x216>
mov    -0xf8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0xa,%eax
jne    12da <handle_CLI+0x1aa>
cmpl   $0x0,-0x1c(%rbp)
je     12b8 <handle_CLI+0x188>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x79,%eax
je     127c <handle_CLI+0x14c>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x59,%eax
jne    1281 <handle_CLI+0x151>
jmp    135a <handle_CLI+0x22a>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x6e,%eax
je     12a7 <handle_CLI+0x177>
mov    -0xf8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x4e,%eax
jne    12ae <handle_CLI+0x17e>
movl   $0x0,-0x1c(%rbp)
jmp    12b3 <handle_CLI+0x183>
jmp    12d5 <handle_CLI+0x1a5>
cmpq   $0x0,-0x8(%rbp)
je     12d0 <handle_CLI+0x1a0>
mov    -0x8(%rbp),%rax
mov    -0xf8(%rbp),%rdi
call   *%rax
jmp    12d5 <handle_CLI+0x1a5>
jmp    1341 <handle_CLI+0x211>
mov    -0xf8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x30,%eax
jl     131f <handle_CLI+0x1ef>
mov    -0xf8(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x39,%eax
jg     131f <handle_CLI+0x1ef>
cmpq   $0x0,-0x10(%rbp)
je     131a <handle_CLI+0x1ea>
mov    -0x10(%rbp),%rax
mov    -0xf8(%rbp),%rdi
call   *%rax
jmp    133c <handle_CLI+0x20c>
cmpq   $0x0,-0x18(%rbp)
je     1337 <handle_CLI+0x207>
mov    -0x18(%rbp),%rax
mov    -0xf8(%rbp),%rdi
call   *%rax
jmp    133c <handle_CLI+0x20c>
jmp    1341 <handle_CLI+0x211>
jmp    1346 <handle_CLI+0x216>
jmp    134b <handle_CLI+0x21b>
mov    $0x1,%al
test   $0x1,%al
jne    114e <handle_CLI+0x1e>
jmp    135a <handle_CLI+0x22a>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handle_CLI>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
mov    %rdx,0x18(%rsp)
mov    %rsi,0x10(%rsp)
mov    %rdi,0x8(%rsp)
xor    %r12d,%r12d
lea    0xe96(%rip),%r13
mov    0x2e77(%rip),%r14
lea    0x20(%rsp),%r15
lea    0xe8c(%rip),%rbp
jmp    118e <handle_CLI+0x4e>
nop
mov    %rbp,%rdi
call   1040 <printf@plt>
mov    $0x1,%r12d
test   %r12d,%r12d
jne    119b <handle_CLI+0x5b>
mov    %r13,%rdi
call   1040 <printf@plt>
mov    (%r14),%edx
mov    %r15,%rdi
mov    $0xc8,%esi
call   1060 <fgets@plt>
test   %rax,%rax
je     1276 <handle_CLI+0x136>
mov    0x20(%rsp),%al
cmp    $0xa,%al
je     1180 <handle_CLI+0x40>
mov    %r15,%rbx
nop
movsbl %al,%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     11e0 <handle_CLI+0xa0>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
cmp    $0xa,%al
jne    11c0 <handle_CLI+0x80>
jmp    1180 <handle_CLI+0x40>
nopl   0x0(%rax,%rax,1)
mov    (%rbx),%al
cmp    $0xa,%al
je     1180 <handle_CLI+0x40>
mov    0x1(%rbx),%cl
cmp    $0xa,%cl
jne    1207 <handle_CLI+0xc7>
test   %r12d,%r12d
je     123f <handle_CLI+0xff>
mov    $0x1,%r12d
cmp    $0x6d,%al
jg     1260 <handle_CLI+0x120>
cmp    $0x4e,%al
je     1264 <handle_CLI+0x124>
cmp    $0x59,%al
jne    118e <handle_CLI+0x4e>
jmp    1282 <handle_CLI+0x142>
add    $0xd0,%cl
cmp    $0x9,%cl
ja     1227 <handle_CLI+0xe7>
cmpq   $0x0,0x10(%rsp)
je     118e <handle_CLI+0x4e>
mov    %rbx,%rdi
call   *0x10(%rsp)
jmp    118e <handle_CLI+0x4e>
cmpq   $0x0,0x18(%rsp)
je     118e <handle_CLI+0x4e>
mov    %rbx,%rdi
call   *0x18(%rsp)
jmp    118e <handle_CLI+0x4e>
mov    $0x0,%r12d
cmpq   $0x0,0x8(%rsp)
je     118e <handle_CLI+0x4e>
mov    %rbx,%rdi
call   *0x8(%rsp)
xor    %r12d,%r12d
jmp    118e <handle_CLI+0x4e>
cmp    $0x6e,%al
jne    126c <handle_CLI+0x12c>
xor    %r12d,%r12d
jmp    118e <handle_CLI+0x4e>
cmp    $0x79,%al
jne    118e <handle_CLI+0x4e>
jmp    1282 <handle_CLI+0x142>
lea    0xdbd(%rip),%rdi
call   1030 <puts@plt>
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"Command>\00"
@stdin = global i32 0
@.str.1 = [22 x i8] c"Input error, exiting\0A\00"
@.str.2 = [49 x i8] c"Blank Line entered, sure you want to quit [y|n]:\00"
define void @handle_CLI(void (i8*)* %0, void (i8*)* %1, void (i8*)* %2) {
%4 = alloca void (i8*)*
%5 = alloca void (i8*)*
%6 = alloca void (i8*)*
%7 = alloca i32
%8 = alloca [200 x i8]
%9 = alloca i8*
store void (i8*)* %0, void (i8*)** %4
store void (i8*)* %1, void (i8*)** %5
store void (i8*)* %2, void (i8*)** %6
store i32 0, i32* %7
br label %10
10: ; preds = %117, %3
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %15, label %13
13: ; preds = %10
%14 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
%16 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%17 = load i32, i32* @stdin
%18 = call i32* @fgets(i8* %16, i32 200, i32 %17)
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %118
22: ; preds = %15
%23 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
store i8* %23, i8** %9
br label %24
24: ; preds = %37, %22
%25 = load i8*, i8** %9
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp ne i32 %27, 10
br i1 %28, label %29, label %34
29: ; preds = %24
%30 = load i8*, i8** %9
%31 = load i8, i8* %30
%32 = call i64 @isspace(i8 signext %31)
%33 = icmp ne i64 %32, 0
br label %34
34: ; preds = %29, %24
%35 = phi i1 [ false, %24 ], [ %33, %29 ]
br i1 %35, label %36, label %40
36: ; preds = %34
br label %37
37: ; preds = %36
%38 = load i8*, i8** %9
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %9
br label %24
40: ; preds = %34
%41 = load i8*, i8** %9
%42 = load i8, i8* %41
%43 = sext i8 %42 to i32
%44 = icmp eq i32 %43, 10
br i1 %44, label %45, label %47
45: ; preds = %40
%46 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %7
br label %116
47: ; preds = %40
%48 = load i8*, i8** %9
%49 = getelementptr inbounds i8, i8* %48, i64 1
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = icmp eq i32 %51, 10
br i1 %52, label %53, label %88
53: ; preds = %47
%54 = load i32, i32* %7
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %80
56: ; preds = %53
%57 = load i8*, i8** %9
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 121
br i1 %60, label %66, label %61
61: ; preds = %56
%62 = load i8*, i8** %9
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp eq i32 %64, 89
br i1 %65, label %66, label %67
66: ; preds = %61, %56
br label %118
67: ; preds = %61
%68 = load i8*, i8** %9
%69 = load i8, i8* %68
%70 = sext i8 %69 to i32
%71 = icmp eq i32 %70, 110
br i1 %71, label %77, label %72
72: ; preds = %67
%73 = load i8*, i8** %9
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 78
br i1 %76, label %77, label %78
77: ; preds = %72, %67
store i32 0, i32* %7
br label %78
78: ; preds = %77, %72
br label %79
79: ; preds = %78
br label %87
80: ; preds = %53
%81 = load void (i8*)*, void (i8*)** %4
%82 = icmp ne void (i8*)* %81, null
br i1 %82, label %83, label %86
83: ; preds = %80
%84 = load void (i8*)*, void (i8*)** %4
%85 = load i8*, i8** %9
br label %86
86: ; preds = %83, %80
br label %87
87: ; preds = %86, %79
br label %115
88: ; preds = %47
%89 = load i8*, i8** %9
%90 = getelementptr inbounds i8, i8* %89, i64 1
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp sge i32 %92, 48
br i1 %93, label %94, label %107
94: ; preds = %88
%95 = load i8*, i8** %9
%96 = getelementptr inbounds i8, i8* %95, i64 1
%97 = load i8, i8* %96
%98 = sext i8 %97 to i32
%99 = icmp sle i32 %98, 57
br i1 %99, label %100, label %107
100: ; preds = %94
%101 = load void (i8*)*, void (i8*)** %5
%102 = icmp ne void (i8*)* %101, null
br i1 %102, label %103, label %106
103: ; preds = %100
%104 = load void (i8*)*, void (i8*)** %5
%105 = load i8*, i8** %9
br label %106
106: ; preds = %103, %100
br label %114
107: ; preds = %94, %88
%108 = load void (i8*)*, void (i8*)** %6
%109 = icmp ne void (i8*)* %108, null
br i1 %109, label %110, label %113
110: ; preds = %107
%111 = load void (i8*)*, void (i8*)** %6
%112 = load i8*, i8** %9
br label %113
113: ; preds = %110, %107
br label %114
114: ; preds = %113, %106
br label %115
115: ; preds = %114, %87
br label %116
116: ; preds = %115, %45
br label %117
117: ; preds = %116
br i1 true, label %10, label %118
118: ; preds = %117, %66, %20
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"Command>\00"
@stdin = global i32 0
@.str.2 = [49 x i8] c"Blank Line entered, sure you want to quit [y|n]:\00"
@str = [21 x i8] c"Input error, exiting\00"
define void @handle_CLI(void (i8*)* %0, void (i8*)* %1, void (i8*)* %2) {
%4 = alloca [200 x i8]
%5 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%6 = icmp eq void (i8*)* %2, null
%7 = icmp eq void (i8*)* %1, null
%8 = icmp eq void (i8*)* %0, null
br label %9
9: ; preds = %37, %3
%10 = phi i32 [ 0, %3 ], [ %38, %37 ]
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %9
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12, %9
%15 = load i32, i32* @stdin
%16 = call i32* @fgets(i8* %5, i32 200, i32 %15)
%17 = icmp eq i32* %16, null
br i1 %17, label %21, label %18
18: ; preds = %14
%19 = load i8, i8* %5
%20 = icmp eq i8 %19, 10
br i1 %20, label %35, label %23
21: ; preds = %14
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %55
23: ; preds = %18, %28
%24 = phi i8 [ %30, %28 ], [ %19, %18 ]
%25 = phi i8* [ %29, %28 ], [ %5, %18 ]
%26 = call i64 @isspace(i8 signext %24)
%27 = icmp eq i64 %26, 0
br i1 %27, label %32, label %28
28: ; preds = %23
%29 = getelementptr inbounds i8, i8* %25, i64 1
%30 = load i8, i8* %29
%31 = icmp eq i8 %30, 10
br i1 %31, label %35, label %23
32: ; preds = %23
%33 = load i8, i8* %25
%34 = icmp eq i8 %33, 10
br i1 %34, label %35, label %39
35: ; preds = %28, %18, %32
%36 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.2, i64 0, i64 0))
br label %37
37: ; preds = %35, %52, %51, %54, %53, %45, %47, %46, %44
%38 = phi i32 [ 1, %35 ], [ 0, %45 ], [ 0, %47 ], [ 0, %46 ], [ %10, %52 ], [ %10, %51 ], [ %10, %54 ], [ %10, %53 ], [ 1, %44 ]
br label %9
39: ; preds = %32
%40 = getelementptr inbounds i8, i8* %25, i64 1
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 10
br i1 %42, label %43, label %48
43: ; preds = %39
br i1 %11, label %46, label %44
44: ; preds = %43
switch i8 %33, label %37 [
i8 121, label %55
i8 89, label %55
i8 110, label %45
i8 78, label %45
]
45: ; preds = %44, %44
br label %37
46: ; preds = %43
br i1 %8, label %37, label %47
47: ; preds = %46
br label %37
48: ; preds = %39
%49 = add i8 %41, -48
%50 = icmp ult i8 %49, 10
br i1 %50, label %51, label %53
51: ; preds = %48
br i1 %7, label %37, label %52
52: ; preds = %51
br label %37
53: ; preds = %48
br i1 %6, label %37, label %54
54: ; preds = %53
br label %37
55: ; preds = %44, %44, %21
ret void
}