#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*/ accept(int *, unsigned int *);
int /*<<< orphan*/ display(int *, unsigned int);
char *getstr();
int /*<<< orphan*/ isvaliddate(unsigned int, unsigned int, unsigned int);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int scanf(char *, unsigned int *, ...);
int /*<<< orphan*/ sort(int *, unsigned int);
char *strsearch(char *, char *);
int main() {
  unsigned n, ch;
  int a[50];
  char *s1, *s2, *f;
  unsigned y, m, d;
  n = 0;
  do {
    puts("What would you like to do?");
    puts(" ( 0) Exit");
    puts(" ( 1) Populate Array");
    puts(" ( 2) Sort");
    puts(" ( 3) Check Date Validity");
    puts(" ( 4) String Search");
    scanf(" %u%*c", &ch);
    switch (ch) {
    case 0:
      puts("Bye!");
      break;
    case 1:
      accept(a, &n);
      break;
    case 2:
      sort(a, n);
      puts("Sorted Array:");
      display(a, n);
      break;
    case 3:
      puts("Enter date in ISO format (yyyy-mm-dd):");
      if (scanf(" %u-%u-%u%*c", &y, &m, &d) < 3 || !isvaliddate(y, m, d))
        puts("Invalid Date.");
      else
        puts("Valid Date.");
      break;
    case 4:
      puts("Enter first string:");
      s1 = getstr();
      puts("Enter string to search:");
      s2 = getstr();
      if (!(f = strsearch(s1, s2)))
        puts("Not Found.");
      else
        printf("Found at position: %u\n", (unsigned)(f - s1) + 1);
      break;
    default:
      puts("Incorrect Choice!");
      break;
    }
  } while (ch);
  putchar('\n');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe54(%rip),%rdi
call   1040 <puts@plt>
lea    0xe63(%rip),%rdi
call   1040 <puts@plt>
lea    0xe62(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6a(%rip),%rdi
call   1040 <puts@plt>
lea    0xe78(%rip),%rdi
call   1040 <puts@plt>
lea    0xe80(%rip),%rdi
xor    %eax,%eax
lea    -0xc(%rbp),%rsi
call   10b0 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %rax,-0x110(%rbp)
sub    $0x4,%rax
ja     139d <main+0x1fd>
mov    -0x110(%rbp),%rax
lea    0xdcb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe4a(%rip),%rdi
call   1040 <puts@plt>
jmp    13a9 <main+0x209>
lea    -0xe0(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   10c0 <accept@plt>
jmp    13a9 <main+0x209>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1080 <sort@plt>
lea    0xe1a(%rip),%rdi
call   1040 <puts@plt>
lea    -0xe0(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <display@plt>
jmp    13a9 <main+0x209>
lea    0xe08(%rip),%rdi
call   1040 <puts@plt>
lea    0xe23(%rip),%rdi
lea    -0xfc(%rbp),%rsi
lea    -0x100(%rbp),%rdx
lea    -0x104(%rbp),%rcx
mov    $0x0,%al
call   10b0 <scanf@plt>
cmp    $0x3,%eax
jl     12eb <main+0x14b>
mov    -0xfc(%rbp),%edi
mov    -0x100(%rbp),%esi
mov    -0x104(%rbp),%edx
call   1060 <isvaliddate@plt>
cmp    $0x0,%eax
jne    12fc <main+0x15c>
lea    0xde4(%rip),%rdi
call   1040 <puts@plt>
jmp    1308 <main+0x168>
lea    0xde1(%rip),%rdi
call   1040 <puts@plt>
jmp    13a9 <main+0x209>
lea    0xddc(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1090 <getstr@plt>
mov    %rax,-0xe8(%rbp)
lea    0xdd6(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1090 <getstr@plt>
mov    %rax,-0xf0(%rbp)
mov    -0xe8(%rbp),%rdi
mov    -0xf0(%rbp),%rsi
call   10a0 <strsearch@plt>
mov    %rax,-0xf8(%rbp)
cmp    $0x0,%rax
jne    1376 <main+0x1d6>
lea    0xdb0(%rip),%rdi
call   1040 <puts@plt>
jmp    1398 <main+0x1f8>
mov    -0xf8(%rbp),%rax
mov    -0xe8(%rbp),%rcx
sub    %rcx,%rax
mov    %eax,%esi
add    $0x1,%esi
lea    0xd94(%rip),%rdi
call   1070 <printf@plt>
jmp    13a9 <main+0x209>
lea    0xd9a(%rip),%rdi
call   1040 <puts@plt>
jmp    13ae <main+0x20e>
cmpl   $0x0,-0xc(%rbp)
jne    11b9 <main+0x19>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xe8,%rsp
movl   $0x0,0xc(%rsp)
lea    0xe54(%rip),%r12
lea    0xe68(%rip),%r15
lea    0xe6c(%rip),%r14
lea    0xe7a(%rip),%r13
lea    0xe7e(%rip),%rbx
lea    0xe91(%rip),%rbp
jmp    11fc <main+0x5c>
lea    0xf52(%rip),%rdi
call   1040 <puts@plt>
cmpl   $0x0,0x10(%rsp)
je     1379 <main+0x1d9>
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r13,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
call   1040 <puts@plt>
lea    0xe55(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   10b0 <scanf@plt>
mov    0x10(%rsp),%eax
cmp    $0x4,%rax
ja     11e5 <main+0x45>
lea    0xdb0(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe2f(%rip),%rdi
jmp    11ec <main+0x4c>
lea    0x20(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   10c0 <accept@plt>
jmp    11f1 <main+0x51>
mov    0xc(%rsp),%esi
lea    0x20(%rsp),%rdi
call   1080 <sort@plt>
lea    0xe09(%rip),%rdi
call   1040 <puts@plt>
mov    0xc(%rsp),%esi
lea    0x20(%rsp),%rdi
call   1050 <display@plt>
jmp    11f1 <main+0x51>
lea    0xdf8(%rip),%rdi
call   1040 <puts@plt>
lea    0xe13(%rip),%rdi
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
xor    %eax,%eax
call   10b0 <scanf@plt>
cmp    $0x3,%eax
jl     1344 <main+0x1a4>
mov    0x1c(%rsp),%edi
mov    0x18(%rsp),%esi
mov    0x14(%rsp),%edx
call   1060 <isvaliddate@plt>
test   %eax,%eax
je     1344 <main+0x1a4>
lea    0xdf7(%rip),%rdi
jmp    11ec <main+0x4c>
mov    %r12,%rbx
lea    0xdf4(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <getstr@plt>
mov    %rax,%r12
lea    0xdf2(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1090 <getstr@plt>
mov    %r12,%rdi
mov    %rax,%rsi
call   10a0 <strsearch@plt>
test   %rax,%rax
je     1350 <main+0x1b0>
sub    %r12d,%eax
add    $0x1,%eax
lea    0xdec(%rip),%rdi
mov    %eax,%esi
call   1070 <printf@plt>
jmp    135c <main+0x1bc>
lea    0xd8b(%rip),%rdi
jmp    11ec <main+0x4c>
lea    0xdc5(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%r12
lea    0xce9(%rip),%r13
lea    0xced(%rip),%rbx
lea    0xd00(%rip),%rbp
jmp    11f1 <main+0x51>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [27 x i8] c"What would you like to do?\00"
@.str.1 = [11 x i8] c" ( 0) Exit\00"
@.str.2 = [21 x i8] c" ( 1) Populate Array\00"
@.str.3 = [11 x i8] c" ( 2) Sort\00"
@.str.4 = [26 x i8] c" ( 3) Check Date Validity\00"
@.str.5 = [20 x i8] c" ( 4) String Search\00"
@.str.6 = [7 x i8] c" %u%*c\00"
@.str.7 = [5 x i8] c"Bye!\00"
@.str.8 = [14 x i8] c"Sorted Array:\00"
@.str.9 = [39 x i8] c"Enter date in ISO format (yyyy-mm-dd):\00"
@.str.10 = [13 x i8] c" %u-%u-%u%*c\00"
@.str.11 = [14 x i8] c"Invalid Date.\00"
@.str.12 = [12 x i8] c"Valid Date.\00"
@.str.13 = [20 x i8] c"Enter first string:\00"
@.str.14 = [24 x i8] c"Enter string to search:\00"
@.str.15 = [11 x i8] c"Not Found.\00"
@.str.16 = [23 x i8] c"Found at position: %u\0A\00"
@.str.17 = [18 x i8] c"Incorrect Choice!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [50 x i32]
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %11
11: ; preds = %72, %0
%12 = call i32 @puts(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 @puts(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %3
switch i32 %19, label %69 [
i32 0, label %20
i32 1, label %22
i32 2, label %25
i32 3, label %33
i32 4, label %48
]
20: ; preds = %11
%21 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %71
22: ; preds = %11
%23 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%24 = call i32 @accept(i32* %23, i32* %2)
br label %71
25: ; preds = %11
%26 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%27 = load i32, i32* %2
%28 = call i32 @sort(i32* %26, i32 %27)
%29 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%30 = getelementptr inbounds [50 x i32], [50 x i32]* %4, i64 0, i64 0
%31 = load i32, i32* %2
%32 = call i32 @display(i32* %30, i32 %31)
br label %71
33: ; preds = %11
%34 = call i32 @puts(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
%35 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32* %8, i32* %9, i32* %10)
%36 = icmp slt i32 %35, 3
br i1 %36, label %43, label %37
37: ; preds = %33
%38 = load i32, i32* %8
%39 = load i32, i32* %9
%40 = load i32, i32* %10
%41 = call i32 @isvaliddate(i32 %38, i32 %39, i32 %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %37, %33
%44 = call i32 @puts(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
br label %47
45: ; preds = %37
%46 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %47
47: ; preds = %45, %43
br label %71
48: ; preds = %11
%49 = call i32 @puts(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0))
%50 = call i8* (...) @getstr()
store i8* %50, i8** %5
%51 = call i32 @puts(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0))
%52 = call i8* (...) @getstr()
store i8* %52, i8** %6
%53 = load i8*, i8** %5
%54 = load i8*, i8** %6
%55 = call i8* @strsearch(i8* %53, i8* %54)
store i8* %55, i8** %7
%56 = icmp ne i8* %55, null
br i1 %56, label %59, label %57
57: ; preds = %48
%58 = call i32 @puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
br label %68
59: ; preds = %48
%60 = load i8*, i8** %7
%61 = load i8*, i8** %5
%62 = ptrtoint i8* %60 to i64
%63 = ptrtoint i8* %61 to i64
%64 = sub i64 %62, %63
%65 = trunc i64 %64 to i32
%66 = add i32 %65, 1
%67 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0), i32 %66)
br label %68
68: ; preds = %59, %57
br label %71
69: ; preds = %11
%70 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
br label %71
71: ; preds = %69, %68, %47, %25, %22, %20
br label %72
72: ; preds = %71
%73 = load i32, i32* %3
%74 = icmp ne i32 %73, 0
br i1 %74, label %11, label %75
75: ; preds = %72
%76 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"What would you like to do?\00"
@.str.1 = [11 x i8] c" ( 0) Exit\00"
@.str.2 = [21 x i8] c" ( 1) Populate Array\00"
@.str.3 = [11 x i8] c" ( 2) Sort\00"
@.str.4 = [26 x i8] c" ( 3) Check Date Validity\00"
@.str.5 = [20 x i8] c" ( 4) String Search\00"
@.str.6 = [7 x i8] c" %u%*c\00"
@.str.7 = [5 x i8] c"Bye!\00"
@.str.8 = [14 x i8] c"Sorted Array:\00"
@.str.9 = [39 x i8] c"Enter date in ISO format (yyyy-mm-dd):\00"
@.str.10 = [13 x i8] c" %u-%u-%u%*c\00"
@.str.11 = [14 x i8] c"Invalid Date.\00"
@.str.12 = [12 x i8] c"Valid Date.\00"
@.str.13 = [20 x i8] c"Enter first string:\00"
@.str.14 = [24 x i8] c"Enter string to search:\00"
@.str.15 = [11 x i8] c"Not Found.\00"
@.str.16 = [23 x i8] c"Found at position: %u\0A\00"
@.str.17 = [18 x i8] c"Incorrect Choice!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [50 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast [50 x i32]* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %1
%13 = getelementptr inbounds [50 x i32], [50 x i32]* %3, i64 0, i64 0
br label %14
14: ; preds = %65, %0
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%22 = load i32, i32* %2
switch i32 %22, label %63 [
i32 0, label %23
i32 1, label %25
i32 2, label %27
i32 3, label %33
i32 4, label %47
]
23: ; preds = %14
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0))
br label %65
25: ; preds = %14
%26 = call i32 @accept(i32* %13, i32* %1)
br label %65
27: ; preds = %14
%28 = load i32, i32* %1
%29 = call i32 @sort(i32* %13, i32 %28)
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%31 = load i32, i32* %1
%32 = call i32 @display(i32* %13, i32 %31)
br label %65
33: ; preds = %14
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.9, i64 0, i64 0))
%35 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i64 0, i64 0), i32* %4, i32* %5, i32* %6)
%36 = icmp slt i32 %35, 3
br i1 %36, label %43, label %37
37: ; preds = %33
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = load i32, i32* %6
%41 = call i32 @isvaliddate(i32 %38, i32 %39, i32 %40)
%42 = icmp eq i32 %41, 0
br i1 %42, label %43, label %45
43: ; preds = %37, %33
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.11, i64 0, i64 0))
br label %65
45: ; preds = %37
%46 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0))
br label %65
47: ; preds = %14
%48 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0))
%49 = call i8* (...) @getstr()
%50 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.14, i64 0, i64 0))
%51 = call i8* (...) @getstr()
%52 = call i8* @strsearch(i8* %49, i8* %51)
%53 = icmp eq i8* %52, null
br i1 %53, label %54, label %56
54: ; preds = %47
%55 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.15, i64 0, i64 0))
br label %65
56: ; preds = %47
%57 = ptrtoint i8* %52 to i64
%58 = ptrtoint i8* %49 to i64
%59 = sub i64 %57, %58
%60 = trunc i64 %59 to i32
%61 = add i32 %60, 1
%62 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.16, i64 0, i64 0), i32 %61)
br label %65
63: ; preds = %14
%64 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
br label %65
65: ; preds = %23, %25, %27, %63, %45, %43, %56, %54
%66 = load i32, i32* %2
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %14
68: ; preds = %65
%69 = call i32 @putchar(i8 signext 10)
ret i32 0
}