#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*/ clear();
int find(int);
int findLast(int);
int /*<<< orphan*/ pop();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ push(int);
int /*<<< orphan*/ scanf(char *, int *);
int seek(int);
int /*<<< orphan*/ wait();
void processInput(int res) {
  int arg = 0;
  switch (res) {
  case 1:
    printf("Value to add: ");
    if (scanf("%d", &arg))
      push(arg);
    break;
  case 2:
    pop();
    break;
  case 3:
    clear();
    break;
  case 4:
    printf("Position to seek: ");
    if (scanf("%d", &arg)) {
      int val = seek(arg);
      printf("Value of element %d is %i\n", arg, val);
      wait();
    }
    break;
  case 5:
    printf("Value to find: ");
    if (scanf("%d", &arg)) {
      int val = find(arg);
      printf("Position of element with value %d is %i\n", arg, val);
      wait();
    }
  case 6:
    printf("value to find: ");
    if (scanf("%d", &arg)) {
      int val = findLast(arg);
      printf("Position of last element with value %d is %i\n", arg, val);
      wait();
    }
  }
}


x86 assembly (clang, -O0):
<processInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x5,%eax
ja     130d <processInput+0x17d>
mov    -0x20(%rbp),%rax
lea    0xe3e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe47(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmp    $0x0,%eax
je     11fa <processInput+0x6a>
mov    -0x8(%rbp),%edi
call   1080 <push@plt>
jmp    130d <processInput+0x17d>
mov    $0x0,%al
call   1040 <pop@plt>
jmp    130d <processInput+0x17d>
mov    $0x0,%al
call   10a0 <clear@plt>
jmp    130d <processInput+0x17d>
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdfb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmp    $0x0,%eax
je     1264 <processInput+0xd4>
mov    -0x8(%rbp),%edi
call   1090 <seek@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   10b0 <wait@plt>
jmp    130d <processInput+0x17d>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xda9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmp    $0x0,%eax
je     12b6 <processInput+0x126>
mov    -0x8(%rbp),%edi
call   1050 <find@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   10b0 <wait@plt>
jmp    12bb <processInput+0x12b>
lea    0xdcf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd57(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
cmp    $0x0,%eax
je     1308 <processInput+0x178>
mov    -0x8(%rbp),%edi
call   1060 <findLast@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xda7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   10b0 <wait@plt>
jmp    130d <processInput+0x17d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<processInput>:
push   %rax
movl   $0x0,0x4(%rsp)
add    $0xffffffff,%edi
cmp    $0x5,%edi
ja     12c2 <processInput+0x132>
lea    0xe54(%rip),%rax
movslq (%rax,%rdi,4),%rcx
add    %rax,%rcx
jmp    *%rcx
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5d(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
test   %eax,%eax
je     12c2 <processInput+0x132>
mov    0x4(%rsp),%edi
call   1080 <push@plt>
pop    %rax
ret
xor    %eax,%eax
pop    %rcx
jmp    1040 <pop@plt>
xor    %eax,%eax
pop    %rcx
jmp    10a0 <clear@plt>
lea    0xe2c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe1b(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
test   %eax,%eax
je     12c2 <processInput+0x132>
mov    0x4(%rsp),%edi
call   1090 <seek@plt>
mov    0x4(%rsp),%esi
lea    0xe0b(%rip),%rdi
jmp    12b2 <processInput+0x122>
lea    0xe1d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xdde(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
test   %eax,%eax
je     127b <processInput+0xeb>
mov    0x4(%rsp),%edi
call   1050 <find@plt>
mov    0x4(%rsp),%esi
lea    0xdfd(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   10b0 <wait@plt>
lea    0xe0f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd97(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <scanf@plt>
test   %eax,%eax
je     12c2 <processInput+0x132>
mov    0x4(%rsp),%edi
call   1060 <findLast@plt>
mov    0x4(%rsp),%esi
lea    0xdef(%rip),%rdi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   10b0 <wait@plt>
pop    %rax
ret

LLVM IR (-O0):
@.str = [15 x i8] c"Value to add: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Position to seek: \00"
@.str.3 = [27 x i8] c"Value of element %d is %i\0A\00"
@.str.4 = [16 x i8] c"Value to find: \00"
@.str.5 = [41 x i8] c"Position of element with value %d is %i\0A\00"
@.str.6 = [16 x i8] c"value to find: \00"
@.str.7 = [46 x i8] c"Position of last element with value %d is %i\0A\00"
define void @processInput(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
%7 = load i32, i32* %2
switch i32 %7, label %56 [
i32 1, label %8
i32 2, label %16
i32 3, label %18
i32 4, label %20
i32 5, label %32
i32 6, label %44
]
8: ; preds = %1
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %8
%13 = load i32, i32* %3
%14 = call i32 @push(i32 %13)
br label %15
15: ; preds = %12, %8
br label %56
16: ; preds = %1
%17 = call i32 (...) @pop()
br label %56
18: ; preds = %1
%19 = call i32 (...) @clear()
br label %56
20: ; preds = %1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %31
24: ; preds = %20
%25 = load i32, i32* %3
%26 = call i32 @seek(i32 %25)
store i32 %26, i32* %4
%27 = load i32, i32* %3
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 %28)
%30 = call i32 (...) @wait()
br label %31
31: ; preds = %24, %20
br label %56
32: ; preds = %1
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %43
36: ; preds = %32
%37 = load i32, i32* %3
%38 = call i32 @find(i32 %37)
store i32 %38, i32* %5
%39 = load i32, i32* %3
%40 = load i32, i32* %5
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %39, i32 %40)
%42 = call i32 (...) @wait()
br label %43
43: ; preds = %36, %32
br label %44
44: ; preds = %1, %43
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %55
48: ; preds = %44
%49 = load i32, i32* %3
%50 = call i32 @findLast(i32 %49)
store i32 %50, i32* %6
%51 = load i32, i32* %3
%52 = load i32, i32* %6
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i32 %51, i32 %52)
%54 = call i32 (...) @wait()
br label %55
55: ; preds = %48, %44
br label %56
56: ; preds = %55, %1, %31, %18, %16, %15
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"Value to add: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Position to seek: \00"
@.str.3 = [27 x i8] c"Value of element %d is %i\0A\00"
@.str.4 = [16 x i8] c"Value to find: \00"
@.str.5 = [41 x i8] c"Position of element with value %d is %i\0A\00"
@.str.6 = [16 x i8] c"value to find: \00"
@.str.7 = [46 x i8] c"Position of last element with value %d is %i\0A\00"
define void @processInput(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
store i32 0, i32* %2
switch i32 %0, label %45 [
i32 1, label %4
i32 2, label %11
i32 3, label %13
i32 4, label %15
i32 5, label %25
i32 6, label %35
]
4: ; preds = %1
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %45, label %8
8: ; preds = %4
%9 = load i32, i32* %2
%10 = call i32 @push(i32 %9)
br label %45
11: ; preds = %1
%12 = tail call i32 (...) @pop()
br label %45
13: ; preds = %1
%14 = tail call i32 (...) @clear()
br label %45
15: ; preds = %1
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%18 = icmp eq i32 %17, 0
br i1 %18, label %45, label %19
19: ; preds = %15
%20 = load i32, i32* %2
%21 = call i32 @seek(i32 %20)
%22 = load i32, i32* %2
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %22, i32 %21)
%24 = call i32 (...) @wait()
br label %45
25: ; preds = %1
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%28 = icmp eq i32 %27, 0
br i1 %28, label %35, label %29
29: ; preds = %25
%30 = load i32, i32* %2
%31 = call i32 @find(i32 %30)
%32 = load i32, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.5, i64 0, i64 0), i32 %32, i32 %31)
%34 = call i32 (...) @wait()
br label %35
35: ; preds = %25, %29, %1
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%37 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%38 = icmp eq i32 %37, 0
br i1 %38, label %45, label %39
39: ; preds = %35
%40 = load i32, i32* %2
%41 = call i32 @findLast(i32 %40)
%42 = load i32, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i32 %42, i32 %41)
%44 = call i32 (...) @wait()
br label %45
45: ; preds = %35, %39, %15, %19, %4, %8, %1, %13, %11
ret void
}