#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 Xn(double, double);
double Yn(double, double);
scalar_t__ pow(double, int);
int /*<<< orphan*/ printf(char *, ...);
double sqrt(scalar_t__);
int /*<<< orphan*/ system(char *);
int main() {
  double x = 0.5, y = 0.7;
  double aux;
  double error = 10;
  double sx = 1;
  double sy = 1;
  double tol = 0.001;
  printf("apartado a)\n\n");
  int i = 0;
  while (error > tol) {
    i++;
    aux = x;
    x = Xn(x, y);
    y = Yn(aux, y);
    printf("x: %lf;y: %lf\n", x, y);
    error = sqrt(pow(sx - x, 2) + pow(sy - y, 2));
  }
  printf("num iter: %d\n", i);
  printf("\napartado b)\n\n");
  i = 0;
  x = 0.25;
  y = 1.5;
  error = 10;
  while (error > tol) {
    i++;
    aux = x;
    x = Xn(x, y);
    y = Yn(aux, y);
    error = sqrt(pow(sx - x, 2) + pow(sy - y, 2));
    if (i > 50) {
      printf("la solucion converge a otra sol: x= %lf; y= %lf", x, y);
      printf("\npresione ENTER para continuar");
      break;
    }
  }
  system("PAUSE");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe7f(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe6a(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe5d(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe48(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x44(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1277 <main+0x117>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <Xn@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1080 <Yn@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe18(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movsd  -0x30(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
mov    %rax,-0x50(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
mov    -0x50(%rbp),%rdi
add    %rax,%rdi
call   1070 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
jmp    11d2 <main+0x72>
mov    -0x44(%rbp),%esi
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdd4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x44(%rbp)
movsd  0xd8b(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xd76(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xd51(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1386 <main+0x226>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1050 <Xn@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1080 <Yn@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x30(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
mov    %rax,-0x58(%rbp)
movsd  -0x38(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
mov    $0x2,%edi
call   1060 <pow@plt>
mov    -0x58(%rbp),%rdi
add    %rax,%rdi
call   1070 <sqrt@plt>
movsd  %xmm0,-0x28(%rbp)
cmpl   $0x32,-0x44(%rbp)
jle    1381 <main+0x221>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xd0b(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    0xd2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1386 <main+0x226>
jmp    12c4 <main+0x164>
lea    0xd34(%rip),%rdi
call   1030 <system@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xf2b(%rip),%rdi
call   1030 <puts@plt>
movsd  0xe74(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe6e(%rip),%xmm0
xor    %ebp,%ebp
lea    0xe95(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%ebp
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm1
call   1060 <Xn@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1090 <Yn@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x2,%al
call   1050 <printf@plt>
movsd  0xe13(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
mov    $0x2,%edi
call   1070 <pow@plt>
mov    %rax,%rbx
movsd  0xdf8(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1070 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1080 <sqrt@plt>
ucomisd 0xddd(%rip),%xmm0
movsd  0x10(%rsp),%xmm0
ja     11b0 <main+0x40>
lea    0xdf9(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe59(%rip),%rdi
call   1030 <puts@plt>
movsd  0xdb5(%rip),%xmm2
movsd  0xdb5(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xdaf(%rip),%xmm0
mov    $0x33,%ebp
cs nopw 0x0(%rax,%rax,1)
ucomisd 0xd80(%rip),%xmm0
jbe    1347 <main+0x1d7>
movapd %xmm2,%xmm0
movsd  0x8(%rsp),%xmm1
movsd  %xmm2,0x18(%rsp)
call   1060 <Xn@plt>
movsd  %xmm0,0x10(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
call   1090 <Yn@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0xd38(%rip),%xmm0
subsd  0x10(%rsp),%xmm0
mov    $0x2,%edi
call   1070 <pow@plt>
mov    %rax,%rbx
movsd  0xd1d(%rip),%xmm0
subsd  0x8(%rsp),%xmm0
mov    $0x2,%edi
call   1070 <pow@plt>
add    %rax,%rbx
mov    %rbx,%rdi
call   1080 <sqrt@plt>
movsd  0x10(%rsp),%xmm1
movapd %xmm1,%xmm2
add    $0xffffffff,%ebp
jne    1290 <main+0x120>
lea    0xd2d(%rip),%rdi
movapd %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
mov    $0x2,%al
call   1050 <printf@plt>
lea    0xd45(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xd56(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [14 x i8] c"apartado a)\0A\0A\00"
@.str.1 = [15 x i8] c"x: %lf;y: %lf\0A\00"
@.str.2 = [14 x i8] c"num iter: %d\0A\00"
@.str.3 = [15 x i8] c"\0Aapartado b)\0A\0A\00"
@.str.4 = [48 x i8] c"la solucion converge a otra sol: x= %lf; y= %lf\00"
@.str.5 = [31 x i8] c"\0Apresione ENTER para continuar\00"
@.str.6 = [6 x i8] c"PAUSE\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i32
store i32 0, i32* %1
store double 5.000000e-01, double* %2
store double 0x3FE6666666666666, double* %3
store double 1.000000e+01, double* %5
store double 1.000000e+00, double* %6
store double 1.000000e+00, double* %7
store double 1.000000e-03, double* %8
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %9
br label %11
11: ; preds = %15, %0
%12 = load double, double* %5
%13 = load double, double* %8
%14 = fcmp ogt double %12, %13
br i1 %14, label %15, label %38
15: ; preds = %11
%16 = load i32, i32* %9
%17 = add nsw i32 %16, 1
store i32 %17, i32* %9
%18 = load double, double* %2
store double %18, double* %4
%19 = load double, double* %2
%20 = load double, double* %3
%21 = call double @Xn(double %19, double %20)
store double %21, double* %2
%22 = load double, double* %4
%23 = load double, double* %3
%24 = call double @Yn(double %22, double %23)
store double %24, double* %3
%25 = load double, double* %2
%26 = load double, double* %3
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %25, double %26)
%28 = load double, double* %6
%29 = load double, double* %2
%30 = fsub double %28, %29
%31 = call i64 @pow(double %30, i32 2)
%32 = load double, double* %7
%33 = load double, double* %3
%34 = fsub double %32, %33
%35 = call i64 @pow(double %34, i32 2)
%36 = add nsw i64 %31, %35
%37 = call double @sqrt(i64 %36)
store double %37, double* %5
br label %11
38: ; preds = %11
%39 = load i32, i32* %9
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %9
store double 2.500000e-01, double* %2
store double 1.500000e+00, double* %3
store double 1.000000e+01, double* %5
br label %42
42: ; preds = %73, %38
%43 = load double, double* %5
%44 = load double, double* %8
%45 = fcmp ogt double %43, %44
br i1 %45, label %46, label %74
46: ; preds = %42
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
%49 = load double, double* %2
store double %49, double* %4
%50 = load double, double* %2
%51 = load double, double* %3
%52 = call double @Xn(double %50, double %51)
store double %52, double* %2
%53 = load double, double* %4
%54 = load double, double* %3
%55 = call double @Yn(double %53, double %54)
store double %55, double* %3
%56 = load double, double* %6
%57 = load double, double* %2
%58 = fsub double %56, %57
%59 = call i64 @pow(double %58, i32 2)
%60 = load double, double* %7
%61 = load double, double* %3
%62 = fsub double %60, %61
%63 = call i64 @pow(double %62, i32 2)
%64 = add nsw i64 %59, %63
%65 = call double @sqrt(i64 %64)
store double %65, double* %5
%66 = load i32, i32* %9
%67 = icmp sgt i32 %66, 50
br i1 %67, label %68, label %73
68: ; preds = %46
%69 = load double, double* %2
%70 = load double, double* %3
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), double %69, double %70)
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %74
73: ; preds = %46
br label %42
74: ; preds = %68, %42
%75 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%76 = load i32, i32* %1
ret i32 %76
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"x: %lf;y: %lf\0A\00"
@.str.2 = [14 x i8] c"num iter: %d\0A\00"
@.str.4 = [48 x i8] c"la solucion converge a otra sol: x= %lf; y= %lf\00"
@.str.5 = [31 x i8] c"\0Apresione ENTER para continuar\00"
@.str.6 = [6 x i8] c"PAUSE\00"
@str = [13 x i8] c"apartado a)\0A\00"
@str.7 = [14 x i8] c"\0Aapartado b)\0A\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i32 [ 0, %0 ], [ %6, %2 ]
%4 = phi double [ 5.000000e-01, %0 ], [ %7, %2 ]
%5 = phi double [ 0x3FE6666666666666, %0 ], [ %8, %2 ]
%6 = add nuw nsw i32 %3, 1
%7 = tail call double @Xn(double %4, double %5)
%8 = tail call double @Yn(double %4, double %5)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), double %7, double %8)
%10 = fsub double 1.000000e+00, %7
%11 = tail call i64 @pow(double %10, i32 2)
%12 = fsub double 1.000000e+00, %8
%13 = tail call i64 @pow(double %12, i32 2)
%14 = add nsw i64 %13, %11
%15 = tail call double @sqrt(i64 %14)
%16 = fcmp ogt double %15, 1.000000e-03
br i1 %16, label %2, label %17
17: ; preds = %2
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
br label %20
20: ; preds = %26, %17
%21 = phi double [ 1.000000e+01, %17 ], [ %35, %26 ]
%22 = phi double [ 1.500000e+00, %17 ], [ %29, %26 ]
%23 = phi double [ 2.500000e-01, %17 ], [ %28, %26 ]
%24 = phi i32 [ 0, %17 ], [ %27, %26 ]
%25 = fcmp ogt double %21, 1.000000e-03
br i1 %25, label %26, label %40
26: ; preds = %20
%27 = add nuw nsw i32 %24, 1
%28 = tail call double @Xn(double %23, double %22)
%29 = tail call double @Yn(double %23, double %22)
%30 = fsub double 1.000000e+00, %28
%31 = tail call i64 @pow(double %30, i32 2)
%32 = fsub double 1.000000e+00, %29
%33 = tail call i64 @pow(double %32, i32 2)
%34 = add nsw i64 %33, %31
%35 = tail call double @sqrt(i64 %34)
%36 = icmp eq i32 %27, 51
br i1 %36, label %37, label %20
37: ; preds = %26
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0), double %28, double %29)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %40
40: ; preds = %20, %37
%41 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
ret i32 0
}