#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*/ isAccepted(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int strlen(char *);
void main() {
  char input[10];
  int length, i;
  int ch0, loop;
  do {
    printf("\nEnter the String to be Accepted: ");
    scanf("%s", input);
    length = strlen(input);
    printf("\n\t1.Only%s\n\t2.Substring %s", input, input);
    printf("\n\t3.Starts with %s\n\t4.Ends with %s\n", input, input);
    scanf("%d", &ch0);
    switch (ch0) {
    case 1:
      isAccepted(input, length + 1);
      break;
    case 2:
      isAccepted(input, length + 1);
      break;
    case 3:
      isAccepted(input, length + 1);
      break;
    case 4:
      isAccepted(input, length + 1);
      break;
    default:
      printf("\nUnidentified Input\n");
    }
    printf("\nTry Another? Press 1\n");
    scanf("%d", &loop);
  } while (loop == 1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xec1(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   1040 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xee8(%rip),%rdi
lea    -0xa(%rbp),%rsi
mov    %rsi,-0x38(%rbp)
call   1050 <scanf@plt>
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x38(%rbp),%rdx
mov    %eax,%ecx
mov    -0x29(%rbp),%al
mov    %ecx,-0x10(%rbp)
lea    0xea7(%rip),%rdi
mov    %rdx,%rsi
call   1040 <printf@plt>
mov    -0x38(%rbp),%rdx
mov    -0x29(%rbp),%al
lea    0xeac(%rip),%rdi
mov    %rdx,%rsi
call   1040 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xebe(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     1236 <main+0xf6>
mov    -0x28(%rbp),%rax
lea    0xe23(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0xa(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
call   1060 <isAccepted@plt>
jmp    1244 <main+0x104>
lea    -0xa(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
call   1060 <isAccepted@plt>
jmp    1244 <main+0x104>
lea    -0xa(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
call   1060 <isAccepted@plt>
jmp    1244 <main+0x104>
lea    -0xa(%rbp),%rdi
mov    -0x10(%rbp),%esi
add    $0x1,%esi
call   1060 <isAccepted@plt>
jmp    1244 <main+0x104>
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe19(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x1,-0x1c(%rbp)
je     1148 <main+0x8>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe(%rsp),%rbx
lea    0xf08(%rip),%rbp
lea    0xf04(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe83(%rip),%r14
jmp    11b0 <main+0x60>
nop
lea    0xf04(%rip),%rdi
call   1030 <puts@plt>
nopl   0x0(%rax)
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
cmpl   $0x1,0x4(%rsp)
jne    123e <main+0xee>
lea    0xe59(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe86(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    %rbx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
lea    0xe52(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe59(%rip),%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1060 <scanf@plt>
mov    0x8(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1180 <main+0x30>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
add    $0x1,%r13d
mov    %rbx,%rdi
mov    %r13d,%esi
call   1070 <isAccepted@plt>
jmp    1190 <main+0x40>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"\0AEnter the String to be Accepted: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [27 x i8] c"\0A\091.Only%s\0A\092.Substring %s\00"
@.str.3 = [36 x i8] c"\0A\093.Starts with %s\0A\094.Ends with %s\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [21 x i8] c"\0AUnidentified Input\0A\00"
@.str.6 = [23 x i8] c"\0ATry Another? Press 1\0A\00"
define void @main() {
%1 = alloca [10 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
br label %6
6: ; preds = %45, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %2
%12 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%13 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %12, i8* %13)
%15 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%16 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %15, i8* %16)
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%19 = load i32, i32* %4
switch i32 %19, label %40 [
i32 1, label %20
i32 2, label %25
i32 3, label %30
i32 4, label %35
]
20: ; preds = %6
%21 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%22 = load i32, i32* %2
%23 = add nsw i32 %22, 1
%24 = call i32 @isAccepted(i8* %21, i32 %23)
br label %42
25: ; preds = %6
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%27 = load i32, i32* %2
%28 = add nsw i32 %27, 1
%29 = call i32 @isAccepted(i8* %26, i32 %28)
br label %42
30: ; preds = %6
%31 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%32 = load i32, i32* %2
%33 = add nsw i32 %32, 1
%34 = call i32 @isAccepted(i8* %31, i32 %33)
br label %42
35: ; preds = %6
%36 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
%39 = call i32 @isAccepted(i8* %36, i32 %38)
br label %42
40: ; preds = %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %40, %35, %30, %25, %20
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0))
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
br label %45
45: ; preds = %42
%46 = load i32, i32* %5
%47 = icmp eq i32 %46, 1
br i1 %47, label %6, label %48
48: ; preds = %45
ret void
}

LLVM IR (-O2):
@.str = [35 x i8] c"\0AEnter the String to be Accepted: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [27 x i8] c"\0A\091.Only%s\0A\092.Substring %s\00"
@.str.3 = [36 x i8] c"\0A\093.Starts with %s\0A\094.Ends with %s\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@str = [22 x i8] c"\0ATry Another? Press 1\00"
@str.7 = [20 x i8] c"\0AUnidentified Input\00"
define void @main() {
%1 = alloca [10 x i8]
%2 = alloca i32
%3 = alloca i32
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
br label %7
7: ; preds = %29, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%10 = call i32 @strlen(i8* %4)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %4, i8* %4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0), i8* %4, i8* %4)
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %2
switch i32 %14, label %27 [
i32 1, label %15
i32 2, label %18
i32 3, label %21
i32 4, label %24
]
15: ; preds = %7
%16 = add nsw i32 %10, 1
%17 = call i32 @isAccepted(i8* %4, i32 %16)
br label %29
18: ; preds = %7
%19 = add nsw i32 %10, 1
%20 = call i32 @isAccepted(i8* %4, i32 %19)
br label %29
21: ; preds = %7
%22 = add nsw i32 %10, 1
%23 = call i32 @isAccepted(i8* %4, i32 %22)
br label %29
24: ; preds = %7
%25 = add nsw i32 %10, 1
%26 = call i32 @isAccepted(i8* %4, i32 %25)
br label %29
27: ; preds = %7
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.7, i64 0, i64 0))
br label %29
29: ; preds = %27, %24, %21, %18, %15
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%32 = load i32, i32* %3
%33 = icmp eq i32 %32, 1
br i1 %33, label %7, label %34
34: ; preds = %29
ret void
}