#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 */
double newtonrap(double, double, double *, int, int *);
double pfijo(double, double, double *, int, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, ...);
double secante(double, double, double, double *, int, int *);
int /*<<< orphan*/ system(char *);
void raices_a() {
  double x0, es, ea, xl = 0, raiz;
  int imax, iter, metodo;
  printf("Elegir el metodo\n");
  printf("1.- Puntofijo\n");
  printf("2.- Newton Rapson\n");
  printf("3.- Secante \n");
  scanf("%d", &metodo);
  printf("\nDar el valor inical X0: ");
  scanf("%lf", &x0);
  printf("\nDar el valor maximo del error es: ");
  scanf("%lf", &es);
  printf("\nDar el numero max de iteraciones imax: ");
  scanf("%d", &imax);
  system("cls");
  switch (metodo) {
  case 1:
    raiz = pfijo(x0, es, &ea, imax, &iter);
    break;
  case 2:
    raiz = newtonrap(x0, es, &ea, imax, &iter);
    break;
  case 3:
    printf("\nDar el valor inical X0: ");
    scanf("%lf", &x0);
    raiz = secante(x0, xl, es, &ea, imax, &iter);
    break;
  default:
    system("cls");
    printf("Opcion incorrecta, introducir una opcion correcta");
    raices_a();
    break;
  }
}


x86 assembly (clang, -O0):
<raices_a>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movq   $0x0,-0x20(%rbp)
lea    0xe79(%rip),%rdi
call   1060 <printf@plt>
lea    0xe7f(%rip),%rdi
call   1060 <printf@plt>
lea    0xe82(%rip),%rdi
call   1060 <printf@plt>
lea    0xe89(%rip),%rdi
call   1060 <printf@plt>
lea    0xe8b(%rip),%rdi
mov    %rdi,-0x48(%rbp)
xor    %eax,%eax
mov    %al,-0x39(%rbp)
lea    -0x34(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xe75(%rip),%rdi
call   1060 <printf@plt>
mov    -0x39(%rbp),%al
lea    0xe80(%rip),%rdi
mov    %rdi,-0x50(%rbp)
lea    -0x8(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xe70(%rip),%rdi
call   1060 <printf@plt>
mov    -0x50(%rbp),%rdi
mov    -0x39(%rbp),%al
lea    -0x10(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xe78(%rip),%rdi
call   1060 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x39(%rbp),%al
lea    -0x2c(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xe85(%rip),%rdi
call   1050 <system@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
sub    $0x1,%eax
je     1266 <raices_a+0xf6>
jmp    1244 <raices_a+0xd4>
mov    -0x38(%rbp),%eax
sub    $0x2,%eax
je     128a <raices_a+0x11a>
jmp    1255 <raices_a+0xe5>
mov    -0x38(%rbp),%eax
sub    $0x3,%eax
je     12ae <raices_a+0x13e>
jmp    12f5 <raices_a+0x185>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x2c(%rbp),%esi
lea    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rdx
call   1080 <pfijo@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1312 <raices_a+0x1a2>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
mov    -0x2c(%rbp),%esi
lea    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rdx
call   1040 <newtonrap@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1312 <raices_a+0x1a2>
lea    0xd90(%rip),%rdi
call   1060 <printf@plt>
lea    0xd9e(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1090 <scanf@plt>
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
mov    -0x2c(%rbp),%esi
lea    -0x18(%rbp),%rdi
lea    -0x30(%rbp),%rdx
call   1070 <secante@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    1312 <raices_a+0x1a2>
lea    0xdb4(%rip),%rdi
call   1050 <system@plt>
lea    0xdac(%rip),%rdi
call   1060 <printf@plt>
call   1030 <raices_a@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<raices_a>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0xf16(%rip),%rdi
call   1040 <puts@plt>
lea    0xf1b(%rip),%rdi
call   1040 <puts@plt>
lea    0xf1d(%rip),%rdi
call   1040 <puts@plt>
lea    0xf23(%rip),%rdi
call   1040 <puts@plt>
lea    0xe42(%rip),%r14
lea    0x1c(%rsp),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   10a0 <scanf@plt>
lea    0xe2f(%rip),%rdi
call   1070 <printf@plt>
lea    0xe3d(%rip),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   10a0 <scanf@plt>
lea    0xe2b(%rip),%rdi
call   1070 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
xor    %eax,%eax
call   10a0 <scanf@plt>
lea    0xe34(%rip),%rdi
call   1070 <printf@plt>
mov    %rsp,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   10a0 <scanf@plt>
lea    0xe44(%rip),%rdi
call   1060 <system@plt>
mov    0x1c(%rsp),%eax
cmp    $0x3,%eax
je     1266 <raices_a+0xe6>
cmp    $0x2,%eax
je     12a8 <raices_a+0x128>
cmp    $0x1,%eax
jne    12c8 <raices_a+0x148>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    (%rsp),%esi
lea    0x20(%rsp),%rdi
lea    0x4(%rsp),%rdx
call   1090 <pfijo@plt>
jmp    12e5 <raices_a+0x165>
lea    0xd96(%rip),%rdi
call   1070 <printf@plt>
lea    0xda4(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   10a0 <scanf@plt>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm2
mov    (%rsp),%esi
lea    0x20(%rsp),%rdi
lea    0x4(%rsp),%rdx
xorps  %xmm1,%xmm1
call   1080 <secante@plt>
jmp    12e5 <raices_a+0x165>
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    (%rsp),%esi
lea    0x20(%rsp),%rdi
lea    0x4(%rsp),%rdx
call   1050 <newtonrap@plt>
jmp    12e5 <raices_a+0x165>
lea    0xd9f(%rip),%rdi
call   1060 <system@plt>
lea    0xd97(%rip),%rdi
call   1070 <printf@plt>
call   1030 <raices_a@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.- Puntofijo\0A\00"
@.str.2 = [19 x i8] c"2.- Newton Rapson\0A\00"
@.str.3 = [14 x i8] c"3.- Secante \0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [26 x i8] c"\0ADar el valor inical X0: \00"
@.str.6 = [4 x i8] c"%lf\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"
define void @raices_a() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store double 0.000000e+00, double* %4
%9 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %8)
%14 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %1)
%16 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %2)
%18 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%20 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%21 = load i32, i32* %8
switch i32 %21, label %40 [
i32 1, label %22
i32 2, label %27
i32 3, label %32
]
22: ; preds = %0
%23 = load double, double* %1
%24 = load double, double* %2
%25 = load i32, i32* %6
%26 = call double @pfijo(double %23, double %24, double* %3, i32 %25, i32* %7)
store double %26, double* %5
br label %43
27: ; preds = %0
%28 = load double, double* %1
%29 = load double, double* %2
%30 = load i32, i32* %6
%31 = call double @newtonrap(double %28, double %29, double* %3, i32 %30, i32* %7)
store double %31, double* %5
br label %43
32: ; preds = %0
%33 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %1)
%35 = load double, double* %1
%36 = load double, double* %4
%37 = load double, double* %2
%38 = load i32, i32* %6
%39 = call double @secante(double %35, double %36, double %37, double* %3, i32 %38, i32* %7)
store double %39, double* %5
br label %43
40: ; preds = %0
%41 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%42 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0))
br label %43
43: ; preds = %40, %32, %27, %22
ret void
}

LLVM IR (-O2):
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [26 x i8] c"\0ADar el valor inical X0: \00"
@.str.6 = [4 x i8] c"%lf\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 = [17 x i8] c"Elegir el metodo\00"
@str.11 = [14 x i8] c"1.- Puntofijo\00"
@str.12 = [18 x i8] c"2.- Newton Rapson\00"
@str.13 = [13 x i8] c"3.- Secante \00"
define void @raices_a() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast double* %1 to i8*
%8 = bitcast double* %2 to i8*
%9 = bitcast double* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast i32* %6 to i8*
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.11, i64 0, i64 0))
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.12, i64 0, i64 0))
%16 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %6)
%18 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %1)
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %2)
%22 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%24 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%25 = load i32, i32* %6
switch i32 %25, label %43 [
i32 1, label %26
i32 2, label %31
i32 3, label %36
]
26: ; preds = %0
%27 = load double, double* %1
%28 = load double, double* %2
%29 = load i32, i32* %4
%30 = call double @pfijo(double %27, double %28, double* %3, i32 %29, i32* %5)
br label %46
31: ; preds = %0
%32 = load double, double* %1
%33 = load double, double* %2
%34 = load i32, i32* %4
%35 = call double @newtonrap(double %32, double %33, double* %3, i32 %34, i32* %5)
br label %46
36: ; preds = %0
%37 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), double* %1)
%39 = load double, double* %1
%40 = load double, double* %2
%41 = load i32, i32* %4
%42 = call double @secante(double %39, double 0.000000e+00, double %40, double* %3, i32 %41, i32* %5)
br label %46
43: ; preds = %0
%44 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0))
%45 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.10, i64 0, i64 0))
br label %46
46: ; preds = %43, %36, %31, %26
ret void
}