#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 */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
void main() {
  double y, xn, div;
  printf("Informe o numero: ");
  scanf("%lf", &y);
  for (int i = 1; i <= 20; i++) {
    if (i == 1) {
      xn = y / 2;
      printf("%d aprox.: %.5lf\n", i, xn);
    } else {
      div = ((xn * xn) - y) / (2 * xn);
      xn = xn - div;
      printf("%d aprox.: %.60lf\n", i, xn);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xede(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x1,-0x1c(%rbp)
cmpl   $0x14,-0x1c(%rbp)
jg     120e <main+0xee>
cmpl   $0x1,-0x1c(%rbp)
jne    1192 <main+0x72>
movsd  -0x8(%rbp),%xmm0
movsd  0xe92(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
lea    0xe99(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11fb <main+0xdb>
movsd  -0x10(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x8(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe38(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x1c(%rbp),%esi
movsd  -0x10(%rbp),%xmm0
lea    0xe3d(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1200 <main+0xe0>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    114d <main+0x2d>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xeda(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm0
mulsd  0xeac(%rip),%xmm0
lea    0xec4(%rip),%rdi
mov    $0x1,%esi
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1030 <printf@plt>
mov    $0x2,%ebx
lea    0xeb8(%rip),%r14
nopl   0x0(%rax)
movsd  0x8(%rsp),%xmm0
movapd %xmm0,%xmm2
mulsd  %xmm0,%xmm2
subsd  0x10(%rsp),%xmm2
movapd %xmm0,%xmm1
addsd  %xmm0,%xmm1
divsd  %xmm1,%xmm2
subsd  %xmm2,%xmm0
mov    %r14,%rdi
mov    %ebx,%esi
movsd  %xmm0,0x8(%rsp)
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x1,%ebx
cmp    $0x15,%ebx
jne    1180 <main+0x60>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [19 x i8] c"Informe o numero: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [18 x i8] c"%d aprox.: %.5lf\0A\00"
@.str.3 = [19 x i8] c"%d aprox.: %.60lf\0A\00"
define void @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 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* %1)
store i32 1, i32* %4
br label %7
7: ; preds = %35, %0
%8 = load i32, i32* %4
%9 = icmp sle i32 %8, 20
br i1 %9, label %10, label %38
10: ; preds = %7
%11 = load i32, i32* %4
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load double, double* %1
%15 = fdiv double %14, 2.000000e+00
store double %15, double* %2
%16 = load i32, i32* %4
%17 = load double, double* %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %16, double %17)
br label %34
19: ; preds = %10
%20 = load double, double* %2
%21 = load double, double* %2
%22 = load double, double* %1
%23 = fneg double %22
%24 = call double @llvm.fmuladd.f64(double %20, double %21, double %23)
%25 = load double, double* %2
%26 = fmul double 2.000000e+00, %25
%27 = fdiv double %24, %26
store double %27, double* %3
%28 = load double, double* %2
%29 = load double, double* %3
%30 = fsub double %28, %29
store double %30, double* %2
%31 = load i32, i32* %4
%32 = load double, double* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %31, double %32)
br label %34
34: ; preds = %19, %13
br label %35
35: ; preds = %34
%36 = load i32, i32* %4
%37 = add nsw i32 %36, 1
store i32 %37, i32* %4
br label %7
38: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"Informe o numero: \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [18 x i8] c"%d aprox.: %.5lf\0A\00"
@.str.3 = [19 x i8] c"%d aprox.: %.60lf\0A\00"
define void @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
%6 = fmul double %5, 5.000000e-01
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 1, double %6)
br label %9
8: ; preds = %9
ret void
9: ; preds = %0, %9
%10 = phi i32 [ 2, %0 ], [ %19, %9 ]
%11 = phi double [ %6, %0 ], [ %17, %9 ]
%12 = load double, double* %1
%13 = fneg double %12
%14 = call double @llvm.fmuladd.f64(double %11, double %11, double %13)
%15 = fmul double %11, 2.000000e+00
%16 = fdiv double %14, %15
%17 = fsub double %11, %16
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i32 %10, double %17)
%19 = add nuw nsw i32 %10, 1
%20 = icmp eq i32 %19, 21
br i1 %20, label %8, label %9
}