#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 fabs(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
main() {
  double n;
  double aprox;
  double antaprox;
  double epsilon;
  do {
    printf("Número: ");
    scanf("%lf", &n);
  } while (n < 0);
  do {
    printf("Raíz cuadrada aproximada: ");
    scanf("%lf", &aprox);
  } while (aprox <= 0);
  do {
    printf("Coeficiente de error: ");
    scanf("%lf", &epsilon);
  } while (epsilon <= 0);
  do {
    antaprox = aprox;
    aprox = (n / antaprox + antaprox) / 2;
  } while (fabs(aprox - antaprox) >= epsilon);
  printf("La raíz cuadrada de %.2lf es %.2lf\n", n, aprox);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     112f <main+0xf>
jmp    1160 <main+0x40>
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jae    1160 <main+0x40>
jmp    1191 <main+0x71>
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe84(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jae    1191 <main+0x71>
jmp    11c2 <main+0xa2>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
divsd  -0x20(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xe1d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x20(%rbp),%xmm0
movaps 0xe13(%rip),%xmm1
pand   %xmm1,%xmm0
ucomisd -0x28(%rbp),%xmm0
jae    11c2 <main+0xa2>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe44(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xef0(%rip),%r14
lea    0xef3(%rip),%r15
lea    0x10(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
xorpd  %xmm0,%xmm0
ucomisd 0x10(%rsp),%xmm0
ja     1140 <main+0x20>
lea    0xec6(%rip),%r14
lea    0xebb(%rip),%r15
lea    0x8(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
xorpd  %xmm0,%xmm0
ucomisd 0x8(%rsp),%xmm0
jae    1180 <main+0x60>
lea    0xea2(%rip),%r14
lea    0xe7b(%rip),%r15
lea    0x18(%rsp),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
movsd  0x18(%rsp),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm2,%xmm0
jae    11c0 <main+0xa0>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0xe07(%rip),%xmm3
movapd 0xe0f(%rip),%xmm4
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movapd %xmm1,%xmm5
movapd %xmm0,%xmm1
divsd  %xmm5,%xmm1
addsd  %xmm5,%xmm1
mulsd  %xmm3,%xmm1
movapd %xmm1,%xmm6
subsd  %xmm5,%xmm6
andpd  %xmm4,%xmm6
ucomisd %xmm2,%xmm6
jae    1210 <main+0xf0>
movsd  %xmm1,0x8(%rsp)
lea    0xe1e(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"N\C3\BAmero: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [28 x i8] c"Ra\C3\ADz cuadrada aproximada: \00"
@.str.3 = [23 x i8] c"Coeficiente de error: \00"
@.str.4 = [37 x i8] c"La ra\C3\ADz cuadrada de %.2lf es %.2lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
br label %6
6: ; preds = %9, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 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* %2)
br label %9
9: ; preds = %6
%10 = load double, double* %2
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %6, label %12
12: ; preds = %9
br label %13
13: ; preds = %16, %12
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
br label %16
16: ; preds = %13
%17 = load double, double* %3
%18 = fcmp ole double %17, 0.000000e+00
br i1 %18, label %13, label %19
19: ; preds = %16
br label %20
20: ; preds = %23, %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%22 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
br label %23
23: ; preds = %20
%24 = load double, double* %5
%25 = fcmp ole double %24, 0.000000e+00
br i1 %25, label %20, label %26
26: ; preds = %23
br label %27
27: ; preds = %35, %26
%28 = load double, double* %3
store double %28, double* %4
%29 = load double, double* %2
%30 = load double, double* %4
%31 = fdiv double %29, %30
%32 = load double, double* %4
%33 = fadd double %31, %32
%34 = fdiv double %33, 2.000000e+00
store double %34, double* %3
br label %35
35: ; preds = %27
%36 = load double, double* %3
%37 = load double, double* %4
%38 = fsub double %36, %37
%39 = call double @llvm.fabs.f64(double %38)
%40 = load double, double* %5
%41 = fcmp oge double %39, %40
br i1 %41, label %27, label %42
42: ; preds = %35
%43 = load double, double* %2
%44 = load double, double* %3
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), double %43, double %44)
%46 = load i32, i32* %1
ret i32 %46
}

LLVM IR (-O2):
@.str = [10 x i8] c"N\C3\BAmero: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [28 x i8] c"Ra\C3\ADz cuadrada aproximada: \00"
@.str.3 = [23 x i8] c"Coeficiente de error: \00"
@.str.4 = [37 x i8] c"La ra\C3\ADz cuadrada de %.2lf es %.2lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = bitcast double* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
br label %7
7: ; preds = %7, %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%10 = load double, double* %1
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %7, label %12
12: ; preds = %7, %12
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%15 = load double, double* %2
%16 = fcmp ugt double %15, 0.000000e+00
br i1 %16, label %17, label %12
17: ; preds = %12, %17
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%20 = load double, double* %3
%21 = fcmp ugt double %20, 0.000000e+00
br i1 %21, label %22, label %17
22: ; preds = %17
%23 = load double, double* %1
%24 = load double, double* %2
br label %25
25: ; preds = %22, %25
%26 = phi double [ %24, %22 ], [ %29, %25 ]
%27 = fdiv double %23, %26
%28 = fadd double %26, %27
%29 = fmul double %28, 5.000000e-01
%30 = fsub double %29, %26
%31 = call double @llvm.fabs.f64(double %30)
%32 = fcmp ult double %31, %20
br i1 %32, label %33, label %25
33: ; preds = %25
store double %29, double* %2
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), double %23, double %29)
ret i32 0
}