#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 busca_elemento(int *, int, int);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ inserir(int *, int *, int);
int /*<<< orphan*/ printf(char *, ...);
int remover(int *, int *, int);
int /*<<< orphan*/ scanf(char *, ...);
int somar_pares(int *, int);
int main() {
  int vetor[50];
  int tamanho = 0;
  int elemento;
  int soma;
  int busca;
  int posicao;
  char opcao;
  int sair = 0;
  while (sair != 1) {
    printf("\nEntre com a OPÇÃO [ I | S | B | R ]: ");
    scanf("%c", &opcao);
    getchar();
    switch (opcao) {
    case 'i':
    case 'I':
      printf("\nInsira o elemento: ");
      scanf("%i", &elemento);
      getchar();
      inserir(vetor, &tamanho, elemento);
      break;
    case 's':
    case 'S':
      soma = somar_pares(vetor, tamanho);
      printf("\nA soma é: %d", soma);
      break;
    case 'B':
    case 'b':
      printf("\nEncontre com o elemento: ");
      scanf("%i", &elemento);
      getchar();
      busca = busca_elemento(vetor, tamanho, elemento);
      printf("\nA busca retornou: %d", busca);
      break;
    case 'R':
    case 'r':
      printf("\nQual posição vc quer remover? ");
      scanf("%d", &posicao);
      printf("O elemento removido foi %d", remover(vetor, &tamanho, posicao));
      break;
    default:
      printf("\n>>> Opção inválida! <<<\n");
      break;
    }
    printf("\nDigite 1 para sair ou 0 para continuar: ");
    scanf("%i", &sair);
    getchar();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xd4(%rbp)
movl   $0x0,-0xec(%rbp)
cmpl   $0x1,-0xec(%rbp)
je     1376 <main+0x206>
lea    0xf1e(%rip),%rdi
xor    %eax,%eax
mov    %al,-0xf9(%rbp)
call   1050 <printf@plt>
mov    -0xf9(%rbp),%al
lea    0xf2d(%rip),%rdi
lea    -0xe5(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0xf9(%rbp),%al
call   1060 <getchar@plt>
movsbl -0xe5(%rbp),%eax
add    $0xffffffbe,%eax
mov    %eax,%ecx
mov    %rcx,-0xf8(%rbp)
sub    $0x31,%eax
ja     1339 <main+0x1c9>
mov    -0xf8(%rbp),%rax
lea    0xdfb(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xedf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0xd8(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0xd0(%rbp),%rdi
mov    -0xd8(%rbp),%edx
lea    -0xd4(%rbp),%rsi
call   1030 <inserir@plt>
jmp    1347 <main+0x1d7>
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%esi
call   1070 <somar_pares@plt>
mov    %eax,-0xdc(%rbp)
mov    -0xdc(%rbp),%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1347 <main+0x1d7>
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe6d(%rip),%rdi
lea    -0xd8(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0xd0(%rbp),%rdi
mov    -0xd4(%rbp),%esi
mov    -0xd8(%rbp),%edx
call   1090 <busca_elemento@plt>
mov    %eax,-0xe0(%rbp)
mov    -0xe0(%rbp),%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1347 <main+0x1d7>
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe4c(%rip),%rdi
lea    -0xe4(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
lea    -0xd0(%rbp),%rdi
mov    -0xe4(%rbp),%edx
lea    -0xd4(%rbp),%rsi
call   1040 <remover@plt>
mov    %eax,%esi
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1347 <main+0x1d7>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdad(%rip),%rdi
lea    -0xec(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
jmp    1196 <main+0x26>
xor    %eax,%eax
add    $0x100,%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,0x10(%rsp)
movl   $0x0,0x18(%rsp)
lea    0xf49(%rip),%r15
lea    0xf(%rsp),%r13
lea    0xfd5(%rip),%rbx
lea    0xf4e(%rip),%rbp
lea    0x18(%rsp),%r12
lea    0xe39(%rip),%r14
jmp    1217 <main+0x97>
nopl   0x0(%rax)
mov    0x10(%rsp),%esi
lea    0x20(%rsp),%rdi
call   1080 <somar_pares@plt>
lea    0xf27(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
cmpl   $0x1,0x18(%rsp)
je     1331 <main+0x1b1>
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r15,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
movsbl 0xf(%rsp),%eax
add    $0xffffffbe,%eax
cmp    $0x31,%eax
ja     1320 <main+0x1a0>
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
lea    0xec1(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
lea    0x20(%rsp),%rdi
call   10a0 <busca_elemento@plt>
lea    0xea6(%rip),%rdi
jmp    11e5 <main+0x65>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbp,%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
mov    0x14(%rsp),%edx
lea    0x20(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <inserir@plt>
jmp    11ee <main+0x6e>
nopl   0x0(%rax)
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe54(%rip),%rdi
lea    0x1c(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x1c(%rsp),%edx
lea    0x20(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1050 <remover@plt>
lea    0xe53(%rip),%rdi
jmp    11e5 <main+0x65>
lea    0xe8c(%rip),%rdi
call   1040 <puts@plt>
jmp    11ee <main+0x6e>
xor    %eax,%eax
add    $0xe8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [41 x i8] c"\0AEntre com a OP\C3\87\C3\83O [ I | S | B | R ]: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [21 x i8] c"\0AInsira o elemento: \00"
@.str.3 = [3 x i8] c"%i\00"
@.str.4 = [15 x i8] c"\0AA soma \C3\A9: %d\00"
@.str.5 = [27 x i8] c"\0AEncontre com o elemento: \00"
@.str.6 = [22 x i8] c"\0AA busca retornou: %d\00"
@.str.7 = [34 x i8] c"\0AQual posi\C3\A7\C3\A3o vc quer remover? \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [27 x i8] c"O elemento removido foi %d\00"
@.str.10 = [29 x i8] c"\0A>>> Op\C3\A7\C3\A3o inv\C3\A1lida! <<<\0A\00"
@.str.11 = [42 x i8] c"\0ADigite 1 para sair ou 0 para continuar: \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %9
br label %10
10: ; preds = %51, %0
%11 = load i32, i32* %9
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %55
13: ; preds = %10
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%16 = call i32 (...) @getchar()
%17 = load i8, i8* %8
%18 = sext i8 %17 to i32
switch i32 %18, label %49 [
i32 105, label %19
i32 73, label %19
i32 115, label %26
i32 83, label %26
i32 66, label %32
i32 98, label %32
i32 82, label %42
i32 114, label %42
]
19: ; preds = %13, %13
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%22 = call i32 (...) @getchar()
%23 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%24 = load i32, i32* %4
%25 = call i32 @inserir(i32* %23, i32* %3, i32 %24)
br label %51
26: ; preds = %13, %13
%27 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%28 = load i32, i32* %3
%29 = call i32 @somar_pares(i32* %27, i32 %28)
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %30)
br label %51
32: ; preds = %13, %13
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%35 = call i32 (...) @getchar()
%36 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%37 = load i32, i32* %3
%38 = load i32, i32* %4
%39 = call i32 @busca_elemento(i32* %36, i32 %37, i32 %38)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %40)
br label %51
42: ; preds = %13, %13
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %7)
%45 = getelementptr inbounds [50 x i32], [50 x i32]* %2, i64 0, i64 0
%46 = load i32, i32* %7
%47 = call i32 @remover(i32* %45, i32* %3, i32 %46)
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i32 %47)
br label %51
49: ; preds = %13
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0))
br label %51
51: ; preds = %49, %42, %32, %26, %19
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0))
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%54 = call i32 (...) @getchar()
br label %10
55: ; preds = %10
ret i32 0
}

LLVM IR (-O2):
@.str = [41 x i8] c"\0AEntre com a OP\C3\87\C3\83O [ I | S | B | R ]: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [21 x i8] c"\0AInsira o elemento: \00"
@.str.3 = [3 x i8] c"%i\00"
@.str.4 = [15 x i8] c"\0AA soma \C3\A9: %d\00"
@.str.5 = [27 x i8] c"\0AEncontre com o elemento: \00"
@.str.6 = [22 x i8] c"\0AA busca retornou: %d\00"
@.str.7 = [34 x i8] c"\0AQual posi\C3\A7\C3\A3o vc quer remover? \00"
@.str.8 = [3 x i8] c"%d\00"
@.str.9 = [27 x i8] c"O elemento removido foi %d\00"
@.str.11 = [42 x i8] c"\0ADigite 1 para sair ou 0 para continuar: \00"
@str = [28 x i8] c"\0A>>> Op\C3\A7\C3\A3o inv\C3\A1lida! <<<\00"
define i32 @main() {
%1 = alloca [50 x i32]
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i32
%7 = bitcast [50 x i32]* %1 to i8*
%8 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%12 = getelementptr inbounds [50 x i32], [50 x i32]* %1, i64 0, i64 0
br label %13
13: ; preds = %0, %45
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%16 = call i32 (...) @getchar()
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
switch i32 %18, label %43 [
i32 105, label %19
i32 73, label %19
i32 115, label %25
i32 83, label %25
i32 66, label %29
i32 98, label %29
i32 82, label %37
i32 114, label %37
]
19: ; preds = %13, %13
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%22 = call i32 (...) @getchar()
%23 = load i32, i32* %3
%24 = call i32 @inserir(i32* %12, i32* %2, i32 %23)
br label %45
25: ; preds = %13, %13
%26 = load i32, i32* %2
%27 = call i32 @somar_pares(i32* %12, i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %27)
br label %45
29: ; preds = %13, %13
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0))
%31 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
%32 = call i32 (...) @getchar()
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = call i32 @busca_elemento(i32* %12, i32 %33, i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i32 %35)
br label %45
37: ; preds = %13, %13
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.7, i64 0, i64 0))
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.8, i64 0, i64 0), i32* %4)
%40 = load i32, i32* %4
%41 = call i32 @remover(i32* %12, i32* %2, i32 %40)
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i32 %41)
br label %45
43: ; preds = %13
%44 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
br label %45
45: ; preds = %43, %37, %29, %25, %19
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.11, i64 0, i64 0))
%47 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%48 = call i32 (...) @getchar()
%49 = load i32, i32* %6
%50 = icmp eq i32 %49, 1
br i1 %50, label %51, label %13
51: ; preds = %45
ret i32 0
}