#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 */
float Bisect(float, float, float, int, float, int *, float *);
float falsa_posicion(float, float, float, int, float, int *, float *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ raices();
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ system(char *);
void raices_c() {
  float xl, xu, es, ea, raiz, xr;
  int imax, iter, metodo;
  printf("Elegir el metodo\n");
  printf("1.- Biseccion\n");
  printf("2.- Falsa posicion\n");
  scanf("%d", &metodo);
  printf("\nDar el valor inical XL: ");
  scanf("%f", &xl);
  printf("\nDar el valor inical XU: ");
  scanf("%f", &xu);
  printf("\nDar el valor maximo del error es: ");
  scanf("%f", &es);
  printf("\nDar el numero max de iteraciones imax: ");
  scanf("%d", &imax);
  xr = xl;
  system("cls");
  switch (metodo) {
  case 1:
    raiz = Bisect(xl, xu, es, imax, xr, &iter, &ea);
    break;
  case 2:
    raiz = falsa_posicion(xl, xu, es, imax, xr, &iter, &ea);
    break;
  default:
    system("cls");
    printf("Opcion incorrecta, introducir una opcion correcta");
    raices();
    break;
  }
  printf("\nLa raiz es: %f", raiz);
  printf("\nEl error es: %f", ea);
  printf("\nEn %d iteraciones", iter);
}


x86 assembly (clang, -O0):
<raices_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xe91(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x29(%rbp)
call   1050 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xe8f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xe94(%rip),%rdi
mov    %rdi,-0x38(%rbp)
lea    -0x24(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
mov    -0x29(%rbp),%al
lea    0xf46(%rip),%rdi
mov    %rdi,-0x40(%rbp)
lea    -0x4(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x29(%rbp),%al
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x29(%rbp),%al
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x29(%rbp),%al
lea    0xe74(%rip),%rdi
call   1050 <printf@plt>
mov    -0x38(%rbp),%rdi
mov    -0x29(%rbp),%al
lea    -0x1c(%rbp),%rsi
call   1070 <scanf@plt>
movss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
lea    0xe77(%rip),%rdi
call   1040 <system@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x1,%eax
je     126c <raices_c+0x10c>
jmp    125b <raices_c+0xfb>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     129a <raices_c+0x13a>
jmp    12c8 <raices_c+0x168>
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
mov    -0x1c(%rbp),%edi
movss  -0x18(%rbp),%xmm3
lea    -0x20(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1060 <Bisect@plt>
movss  %xmm0,-0x14(%rbp)
jmp    12e9 <raices_c+0x189>
movss  -0x4(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
movss  -0xc(%rbp),%xmm2
mov    -0x1c(%rbp),%edi
movss  -0x18(%rbp),%xmm3
lea    -0x20(%rbp),%rsi
lea    -0x10(%rbp),%rdx
call   1030 <falsa_posicion@plt>
movss  %xmm0,-0x14(%rbp)
jmp    12e9 <raices_c+0x189>
lea    0xdea(%rip),%rdi
call   1040 <system@plt>
lea    0xde2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1080 <raices@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf6(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdef(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<raices_c>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xf70(%rip),%rdi
call   1030 <puts@plt>
lea    0xf75(%rip),%rdi
call   1030 <puts@plt>
lea    0xf77(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5e(%rip),%r14
lea    0x24(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xe4b(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xf12(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xe41(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x20(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x1c(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
lea    0xe45(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1080 <scanf@plt>
movss  0x8(%rsp),%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xe45(%rip),%rdi
call   1050 <system@plt>
mov    0x24(%rsp),%eax
cmp    $0x2,%eax
je     127f <raices_c+0x10f>
cmp    $0x1,%eax
jne    12ac <raices_c+0x13c>
movss  0x8(%rsp),%xmm0
movss  0x20(%rsp),%xmm1
movss  0x1c(%rsp),%xmm2
mov    0x14(%rsp),%edi
lea    0x10(%rsp),%rsi
lea    0x18(%rsp),%rdx
movss  0xc(%rsp),%xmm3
call   1070 <Bisect@plt>
jmp    12cd <raices_c+0x15d>
movss  0x8(%rsp),%xmm0
movss  0x20(%rsp),%xmm1
movss  0x1c(%rsp),%xmm2
mov    0x14(%rsp),%edi
lea    0x10(%rsp),%rsi
lea    0x18(%rsp),%rdx
movss  0xc(%rsp),%xmm3
call   1040 <falsa_posicion@plt>
jmp    12cd <raices_c+0x15d>
lea    0xdd1(%rip),%rdi
call   1050 <system@plt>
lea    0xdc9(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1090 <raices@plt>
cvtss2sd %xmm0,%xmm0
lea    0xde2(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
movss  0x18(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdda(%rip),%rdi
mov    $0x1,%al
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
lea    0xdd9(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Elegir el metodo\0A\00"
@.str.1 = [15 x i8] c"1.- Biseccion\0A\00"
@.str.2 = [20 x i8] c"2.- Falsa posicion\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [26 x i8] c"\0ADar el valor inical XL: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [26 x i8] c"\0ADar el valor inical XU: \00"
@.str.7 = [36 x i8] c"\0ADar el valor maximo del error es: \00"
@.str.8 = [41 x i8] c"\0ADar el numero max de iteraciones imax: \00"
@.str.9 = [4 x i8] c"cls\00"
@.str.10 = [50 x i8] c"Opcion incorrecta, introducir una opcion correcta\00"
@.str.11 = [16 x i8] c"\0ALa raiz es: %f\00"
@.str.12 = [17 x i8] c"\0AEl error es: %f\00"
@.str.13 = [19 x i8] c"\0AEn %d iteraciones\00"
define void @raices_c() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %1)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %2)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %3)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, 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* %7)
%22 = load float, float* %1
store float %22, float* %6
%23 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%24 = load i32, i32* %9
switch i32 %24, label %39 [
i32 1, label %25
i32 2, label %32
]
25: ; preds = %0
%26 = load float, float* %1
%27 = load float, float* %2
%28 = load float, float* %3
%29 = load i32, i32* %7
%30 = load float, float* %6
%31 = call float @Bisect(float %26, float %27, float %28, i32 %29, float %30, i32* %8, float* %4)
store float %31, float* %5
br label %43
32: ; preds = %0
%33 = load float, float* %1
%34 = load float, float* %2
%35 = load float, float* %3
%36 = load i32, i32* %7
%37 = load float, float* %6
%38 = call float @falsa_posicion(float %33, float %34, float %35, i32 %36, float %37, i32* %8, float* %4)
store float %38, float* %5
br label %43
39: ; preds = %0
%40 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0))
%42 = call i32 (...) @raices()
br label %43
43: ; preds = %39, %32, %25
%44 = load float, float* %5
%45 = fpext float %44 to double
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), double %45)
%47 = load float, float* %4
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0), double %48)
%50 = load i32, i32* %8
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %50)
ret void
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [26 x i8] c"\0ADar el valor inical XL: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [26 x i8] c"\0ADar el valor inical XU: \00"
@.str.7 = [36 x i8] c"\0ADar el valor maximo del error es: \00"
@.str.8 = [41 x i8] c"\0ADar el numero max de iteraciones imax: \00"
@.str.9 = [4 x i8] c"cls\00"
@.str.10 = [50 x i8] c"Opcion incorrecta, introducir una opcion correcta\00"
@.str.11 = [16 x i8] c"\0ALa raiz es: %f\00"
@.str.12 = [17 x i8] c"\0AEl error es: %f\00"
@.str.13 = [19 x i8] c"\0AEn %d iteraciones\00"
@str = [17 x i8] c"Elegir el metodo\00"
@str.14 = [14 x i8] c"1.- Biseccion\00"
@str.15 = [19 x i8] c"2.- Falsa posicion\00"
define void @raices_c() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast float* %1 to i8*
%9 = bitcast float* %2 to i8*
%10 = bitcast float* %3 to i8*
%11 = bitcast float* %4 to i8*
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.14, i64 0, i64 0))
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.15, i64 0, i64 0))
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %1)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %2)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %3)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%27 = load float, float* %1
%28 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%29 = load i32, i32* %7
switch i32 %29, label %42 [
i32 1, label %30
i32 2, label %36
]
30: ; preds = %0
%31 = load float, float* %1
%32 = load float, float* %2
%33 = load float, float* %3
%34 = load i32, i32* %5
%35 = call float @Bisect(float %31, float %32, float %33, i32 %34, float %27, i32* %6, float* %4)
br label %46
36: ; preds = %0
%37 = load float, float* %1
%38 = load float, float* %2
%39 = load float, float* %3
%40 = load i32, i32* %5
%41 = call float @falsa_posicion(float %37, float %38, float %39, i32 %40, float %27, i32* %6, float* %4)
br label %46
42: ; preds = %0
%43 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0))
%45 = call i32 (...) @raices()
br label %46
46: ; preds = %42, %36, %30
%47 = phi float [ undef, %42 ], [ %41, %36 ], [ %35, %30 ]
%48 = fpext float %47 to double
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.11, i64 0, i64 0), double %48)
%50 = load float, float* %4
%51 = fpext float %50 to double
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0), double %51)
%53 = load i32, i32* %6
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0), i32 %53)
ret void
}