#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 */
typedef int /*<<< orphan*/ lista;

/* Variables and functions */
int busquedaBin(double *, double, int const);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
main() {
  double lista[] = {3,  6,  9,  12, 15, 18, 21, 24, 27, 30,
                    33, 36, 39, 42, 45, 48, 51, 54, 57, 60};
  const int n_elementos = sizeof(lista) / sizeof(float);
  int posicion = 0;
  double valor = 0.0;
  printf("Introducir el valor a buscar ");
  scanf("%lf", &valor);
  posicion = busquedaBin(lista, valor, n_elementos - 1);
  if (posicion != -1)
    printf("\nLa posición de %g es %d\n", valor, posicion);
  else
    printf("\nEl valor %g no está en la lista\n", valor);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xb0(%rbp),%rdi
lea    0xea0(%rip),%rsi
mov    $0xa0,%edx
call   1050 <memcpy@plt>
movl   $0x28,-0xb4(%rbp)
movl   $0x0,-0xb8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0xc0(%rbp)
ff
lea    0xf10(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf20(%rip),%rdi
lea    -0xc0(%rbp),%rsi
call   1060 <scanf@plt>
lea    -0xb0(%rbp),%rdi
movsd  -0xc0(%rbp),%xmm0
ff
mov    $0x27,%esi
call   1030 <busquedaBin@plt>
mov    %eax,-0xb8(%rbp)
cmpl   $0xffffffff,-0xb8(%rbp)
je     11f7 <main+0xb7>
movsd  -0xc0(%rbp),%xmm0
ff
mov    -0xb8(%rbp),%esi
lea    0xed7(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    120d <main+0xcd>
movsd  -0xc0(%rbp),%xmm0
ff
lea    0xed7(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xb0,%rsp
lea    0xeb1(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    $0xa0,%edx
mov    %rbx,%rdi
call   1050 <memcpy@plt>
movq   $0x0,0x8(%rsp)
lea    0xf2f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf3f(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1060 <scanf@plt>
movsd  0x8(%rsp),%xmm0
mov    %rbx,%rdi
mov    $0x27,%esi
call   1030 <busquedaBin@plt>
movsd  0x8(%rsp),%xmm0
cmp    $0xffffffff,%eax
je     11b9 <main+0x79>
lea    0xf14(%rip),%rdi
mov    %eax,%esi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11c7 <main+0x87>
lea    0xf1d(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xb0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.lista = [20 x double] [double 3.000000e+00, double 6.000000e+00, double 9.000000e+00, double 1.200000e+01, double 1.500000e+01, double 1.800000e+01, double 2.100000e+01, double 2.400000e+01, double 2.700000e+01, double 3.000000e+01, double 3.300000e+01, double 3.600000e+01, double 3.900000e+01, double 4.200000e+01, double 4.500000e+01, double 4.800000e+01, double 5.100000e+01, double 5.400000e+01, double 5.700000e+01, double 6.000000e+01]
@.str = [30 x i8] c"Introducir el valor a buscar \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [27 x i8] c"\0ALa posici\C3\B3n de %g es %d\0A\00"
@.str.3 = [35 x i8] c"\0AEl valor %g no est\C3\A1 en la lista\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [20 x double]
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
store i32 0, i32* %1
%6 = bitcast [20 x double]* %2 to i8*
store i32 40, i32* %3
store i32 0, i32* %4
store double 0.000000e+00, double* %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
%9 = getelementptr inbounds [20 x double], [20 x double]* %2, i64 0, i64 0
%10 = load double, double* %5
%11 = call i32 @busquedaBin(double* %9, double %10, i32 39)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, -1
br i1 %13, label %14, label %18
14: ; preds = %0
%15 = load double, double* %5
%16 = load i32, i32* %4
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %15, i32 %16)
br label %21
18: ; preds = %0
%19 = load double, double* %5
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), double %19)
br label %21
21: ; preds = %18, %14
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@__const.main.lista = [20 x double] [double 3.000000e+00, double 6.000000e+00, double 9.000000e+00, double 1.200000e+01, double 1.500000e+01, double 1.800000e+01, double 2.100000e+01, double 2.400000e+01, double 2.700000e+01, double 3.000000e+01, double 3.300000e+01, double 3.600000e+01, double 3.900000e+01, double 4.200000e+01, double 4.500000e+01, double 4.800000e+01, double 5.100000e+01, double 5.400000e+01, double 5.700000e+01, double 6.000000e+01]
@.str = [30 x i8] c"Introducir el valor a buscar \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [27 x i8] c"\0ALa posici\C3\B3n de %g es %d\0A\00"
@.str.3 = [35 x i8] c"\0AEl valor %g no est\C3\A1 en la lista\0A\00"
define i32 @main() {
%1 = alloca [20 x double]
%2 = alloca double
%3 = bitcast [20 x double]* %1 to i8*
%4 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%7 = getelementptr inbounds [20 x double], [20 x double]* %1, i64 0, i64 0
%8 = load double, double* %2
%9 = call i32 @busquedaBin(double* %7, double %8, i32 39)
%10 = icmp eq i32 %9, -1
%11 = load double, double* %2
br i1 %10, label %14, label %12
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), double %11, i32 %9)
br label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), double %11)
br label %16
16: ; preds = %14, %12
ret i32 0
}