#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*/ bubblesort(int *, int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int getMaior(int *, int);
int getMenor(int *, int);
int getTamVetorY(int *, int);
int /*<<< orphan*/ insere_lista_auto(int *, int);
int /*<<< orphan*/ insere_vetorW(int *, int *, int);
int /*<<< orphan*/ insere_vetorY(int *, int *, int);
int /*<<< orphan*/ mostra_lista(int *, int);
int pesquisaBinaria(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
void question_two() {
  int tam_vetorX, tam_vetorY;
  printf("\n------------- Questao 2 -------------\n");
  printf("Tamanho do vetor X: ");
  scanf("%d", &tam_vetorX);
  int vetorX[tam_vetorX];
  insere_lista_auto(vetorX, tam_vetorX);
  tam_vetorY = getTamVetorY(vetorX, tam_vetorX);
  int vetorY[tam_vetorY];
  insere_vetorY(vetorX, vetorY, tam_vetorX);
  printf("Vetor Y:\n");
  mostra_lista(vetorY, tam_vetorY);
  int tam_vetorW = (tam_vetorX / 2) + 1;
  int vetorW[tam_vetorW];
  insere_vetorW(vetorX, vetorW, tam_vetorX);
  printf("Vetor W:\n");
  mostra_lista(vetorW, tam_vetorW);
  printf("o menor do valor do vetor X: %d\n", getMenor(vetorX, tam_vetorX));
  printf("o maior do valor do vetor X: %d\n", getMaior(vetorX, tam_vetorX));
  printf("Vetor X:\n");
  bubblesort(vetorX, tam_vetorX);
  mostra_lista(vetorX, tam_vetorX);
  int busca;
  printf("valor a procurar no vetor X: ");
  fflush(stdin);
  scanf("%d", &busca);
  busca = pesquisaBinaria(vetorX, tam_vetorX, busca);
  if (busca >= 0)
    printf("O valor esta posicao: %d\n", busca);
  else
    printf("Vetor nao possui valor pesquisado.\n");
}


x86 assembly (clang, -O0):
<question_two>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    0xe31(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x51(%rbp)
call   1050 <printf@plt>
mov    -0x51(%rbp),%al
lea    0xe45(%rip),%rdi
call   1050 <printf@plt>
lea    0xe4e(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   10c0 <scanf@plt>
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%esi
call   10e0 <insere_lista_auto@plt>
mov    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1060 <getTamVetorY@plt>
mov    -0x40(%rbp),%rdi
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x50(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%edx
call   1040 <insere_vetorY@plt>
mov    -0x51(%rbp),%al
lea    0xdd4(%rip),%rdi
call   1050 <printf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1090 <mostra_lista@plt>
mov    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %ecx,%eax
sar    %eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rsi
sub    %rcx,%rsi
mov    %rsi,-0x48(%rbp)
mov    %rsi,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x4(%rbp),%edx
call   1030 <insere_vetorW@plt>
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1090 <mostra_lista@plt>
mov    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1080 <getMenor@plt>
mov    %eax,%esi
lea    0xd6a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   10a0 <getMaior@plt>
mov    %eax,%esi
lea    0xd6f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xd82(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   10d0 <bubblesort@plt>
mov    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1090 <mostra_lista@plt>
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2ca0(%rip),%rax
mov    (%rax),%edi
call   10b0 <fflush@plt>
lea    0xce7(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   10c0 <scanf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1070 <pesquisaBinaria@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     1391 <question_two+0x1d1>
mov    -0x34(%rbp),%esi
lea    0xd39(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    139f <question_two+0x1df>
lea    0xd40(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<question_two>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xead(%rip),%rdi
call   1030 <puts@plt>
lea    0xe0f(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe16(%rip),%r14
lea    -0x2c(%rbp),%rsi
mov    %r14,%rdi
call   10d0 <scanf@plt>
mov    %rsp,%r13
mov    -0x2c(%rbp),%eax
mov    %rsp,%r15
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    -0x2c(%rbp),%esi
mov    %r15,%rdi
call   10f0 <insere_lista_auto@plt>
mov    -0x2c(%rbp),%esi
mov    %r15,%rdi
call   1070 <getTamVetorY@plt>
mov    %eax,%r12d
mov    %eax,%eax
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%rbx
sub    %rax,%rbx
mov    %rbx,%rsp
mov    -0x2c(%rbp),%edx
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <insere_vetorY@plt>
lea    0xe4e(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
call   10a0 <mostra_lista@plt>
mov    -0x2c(%rbp),%edx
mov    %edx,%ebx
shr    $0x1f,%ebx
add    %edx,%ebx
sar    %ebx
add    $0x1,%ebx
lea    0xf(,%rbx,4),%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r12
sub    %rax,%r12
mov    %r12,%rsp
mov    %r15,%rdi
mov    %r12,%rsi
call   1040 <insere_vetorW@plt>
lea    0xe11(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
mov    %ebx,%esi
call   10a0 <mostra_lista@plt>
mov    -0x2c(%rbp),%esi
mov    %r15,%rdi
call   1090 <getMenor@plt>
lea    0xd46(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    -0x2c(%rbp),%esi
mov    %r15,%rdi
call   10b0 <getMaior@plt>
lea    0xd4c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xdce(%rip),%rdi
call   1030 <puts@plt>
mov    -0x2c(%rbp),%esi
mov    %r15,%rdi
call   10e0 <bubblesort@plt>
mov    -0x2c(%rbp),%esi
mov    %r15,%rdi
call   10a0 <mostra_lista@plt>
lea    0xd3b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2cbb(%rip),%rax
mov    (%rax),%edi
call   10c0 <fflush@plt>
lea    -0x30(%rbp),%rsi
mov    %r14,%rdi
call   10d0 <scanf@plt>
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    %r15,%rdi
call   1080 <pesquisaBinaria@plt>
mov    %eax,-0x30(%rbp)
test   %eax,%eax
js     1367 <question_two+0x197>
lea    0xd1c(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1373 <question_two+0x1a3>
lea    0xd66(%rip),%rdi
call   1030 <puts@plt>
mov    %r13,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"\0A------------- Questao 2 -------------\0A\00"
@.str.1 = [21 x i8] c"Tamanho do vetor X: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [10 x i8] c"Vetor Y:\0A\00"
@.str.4 = [10 x i8] c"Vetor W:\0A\00"
@.str.5 = [33 x i8] c"o menor do valor do vetor X: %d\0A\00"
@.str.6 = [33 x i8] c"o maior do valor do vetor X: %d\0A\00"
@.str.7 = [10 x i8] c"Vetor X:\0A\00"
@.str.8 = [30 x i8] c"valor a procurar no vetor X: \00"
@stdin = global i32 0
@.str.9 = [26 x i8] c"O valor esta posicao: %d\0A\00"
@.str.10 = [36 x i8] c"Vetor nao possui valor pesquisado.\0A\00"
define void @question_two() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i64
%8 = alloca i32
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %3
%15 = alloca i32, i64 %13
store i64 %13, i64* %4
%16 = load i32, i32* %1
%17 = call i32 @insere_lista_auto(i32* %15, i32 %16)
%18 = load i32, i32* %1
%19 = call i32 @getTamVetorY(i32* %15, i32 %18)
store i32 %19, i32* %2
%20 = load i32, i32* %2
%21 = zext i32 %20 to i64
%22 = alloca i32, i64 %21
store i64 %21, i64* %5
%23 = load i32, i32* %1
%24 = call i32 @insere_vetorY(i32* %15, i32* %22, i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* %2
%27 = call i32 @mostra_lista(i32* %22, i32 %26)
%28 = load i32, i32* %1
%29 = sdiv i32 %28, 2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
%31 = load i32, i32* %6
%32 = zext i32 %31 to i64
%33 = alloca i32, i64 %32
store i64 %32, i64* %7
%34 = load i32, i32* %1
%35 = call i32 @insere_vetorW(i32* %15, i32* %33, i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%37 = load i32, i32* %6
%38 = call i32 @mostra_lista(i32* %33, i32 %37)
%39 = load i32, i32* %1
%40 = call i32 @getMenor(i32* %15, i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %1
%43 = call i32 @getMaior(i32* %15, i32 %42)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %43)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
%46 = load i32, i32* %1
%47 = call i32 @bubblesort(i32* %15, i32 %46)
%48 = load i32, i32* %1
%49 = call i32 @mostra_lista(i32* %15, i32 %48)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
%51 = load i32, i32* @stdin
%52 = call i32 @fflush(i32 %51)
%53 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
%54 = load i32, i32* %1
%55 = load i32, i32* %8
%56 = call i32 @pesquisaBinaria(i32* %15, i32 %54, i32 %55)
store i32 %56, i32* %8
%57 = load i32, i32* %8
%58 = icmp sge i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %0
%60 = load i32, i32* %8
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i32 %60)
br label %64
62: ; preds = %0
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
br label %64
64: ; preds = %62, %59
%65 = load i8*, i8** %3
ret void
}

LLVM IR (-O2):
@.str.1 = [21 x i8] c"Tamanho do vetor X: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.5 = [33 x i8] c"o menor do valor do vetor X: %d\0A\00"
@.str.6 = [33 x i8] c"o maior do valor do vetor X: %d\0A\00"
@.str.8 = [30 x i8] c"valor a procurar no vetor X: \00"
@stdin = global i32 0
@.str.9 = [26 x i8] c"O valor esta posicao: %d\0A\00"
@str = [39 x i8] c"\0A------------- Questao 2 -------------\00"
@str.11 = [9 x i8] c"Vetor Y:\00"
@str.12 = [9 x i8] c"Vetor W:\00"
@str.13 = [9 x i8] c"Vetor X:\00"
@str.14 = [35 x i8] c"Vetor nao possui valor pesquisado.\00"
define void @question_two() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = zext i32 %7 to i64
%9 = call i8* @llvm.stacksave()
%10 = alloca i32, i64 %8
%11 = load i32, i32* %1
%12 = call i32 @insere_lista_auto(i32* %10, i32 %11)
%13 = load i32, i32* %1
%14 = call i32 @getTamVetorY(i32* %10, i32 %13)
%15 = zext i32 %14 to i64
%16 = alloca i32, i64 %15
%17 = load i32, i32* %1
%18 = call i32 @insere_vetorY(i32* %10, i32* %16, i32 %17)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.11, i64 0, i64 0))
%20 = call i32 @mostra_lista(i32* %16, i32 %14)
%21 = load i32, i32* %1
%22 = sdiv i32 %21, 2
%23 = add nsw i32 %22, 1
%24 = zext i32 %23 to i64
%25 = alloca i32, i64 %24
%26 = call i32 @insere_vetorW(i32* %10, i32* %25, i32 %21)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.12, i64 0, i64 0))
%28 = call i32 @mostra_lista(i32* %25, i32 %23)
%29 = load i32, i32* %1
%30 = call i32 @getMenor(i32* %10, i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %1
%33 = call i32 @getMaior(i32* %10, i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %33)
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.13, i64 0, i64 0))
%36 = load i32, i32* %1
%37 = call i32 @bubblesort(i32* %10, i32 %36)
%38 = load i32, i32* %1
%39 = call i32 @mostra_lista(i32* %10, i32 %38)
%40 = bitcast i32* %2 to i8*
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0))
%42 = load i32, i32* @stdin
%43 = call i32 @fflush(i32 %42)
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%45 = load i32, i32* %1
%46 = load i32, i32* %2
%47 = call i32 @pesquisaBinaria(i32* %10, i32 %45, i32 %46)
store i32 %47, i32* %2
%48 = icmp sgt i32 %47, -1
br i1 %48, label %49, label %51
49: ; preds = %0
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.9, i64 0, i64 0), i32 %47)
br label %53
51: ; preds = %0
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.14, i64 0, i64 0))
br label %53
53: ; preds = %51, %49
ret void
}