#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 f1(double);
double fabs(double);
double fd1(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  double x0, x1, cota, error;
  printf("Ingrese x0:");
  scanf("%lf", &x0);
  printf("Ingrese margen de error:");
  scanf("%lf", &error);
  cota = 50;
  while (cota > error) {
    x1 = x0 - f1(x0) / fd1(x0);
    cota = fabs(x1 - x0);
    x0 = x1;
  }
  printf("Tomá: %lf\n", x0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1060 <scanf@plt>
movsd  0xe6d(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    120e <main+0xce>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <f1@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <fd1@plt>
movsd  -0x38(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x30(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xe1a(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1198 <main+0x58>
movsd  -0x10(%rbp),%xmm0
lea    0xe2f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xed4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed2(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <scanf@plt>
movsd  0xe78(%rip),%xmm0
ucomisd 0x8(%rsp),%xmm0
movsd  (%rsp),%xmm1
jbe    11f1 <main+0xb1>
cs nopw 0x0(%rax,%rax,1)
nop
movsd  %xmm1,0x18(%rsp)
movapd %xmm1,%xmm0
call   1040 <f1@plt>
movsd  %xmm0,0x10(%rsp)
movsd  (%rsp),%xmm0
call   1050 <fd1@plt>
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
subsd  (%rsp),%xmm0
andpd  0xe2c(%rip),%xmm0
movsd  %xmm1,(%rsp)
ucomisd 0x8(%rsp),%xmm0
ja     11a0 <main+0x60>
lea    0xe51(%rip),%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"Ingrese x0:\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [25 x i8] c"Ingrese margen de error:\00"
@.str.3 = [12 x i8] c"Tom\C3\A1: %lf\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
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %5)
store double 5.000000e+01, double* %4
br label %10
10: ; preds = %14, %0
%11 = load double, double* %4
%12 = load double, double* %5
%13 = fcmp ogt double %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load double, double* %2
%16 = load double, double* %2
%17 = call double @f1(double %16)
%18 = load double, double* %2
%19 = call double @fd1(double %18)
%20 = fdiv double %17, %19
%21 = fsub double %15, %20
store double %21, double* %3
%22 = load double, double* %3
%23 = load double, double* %2
%24 = fsub double %22, %23
%25 = call double @llvm.fabs.f64(double %24)
store double %25, double* %4
%26 = load double, double* %3
store double %26, double* %2
br label %10
27: ; preds = %10
%28 = load double, double* %2
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %28)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"Ingrese x0:\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [25 x i8] c"Ingrese margen de error:\00"
@.str.3 = [12 x i8] c"Tom\C3\A1: %lf\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = bitcast double* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 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)
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, 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)
%9 = load double, double* %2
%10 = fcmp olt double %9, 5.000000e+01
%11 = load double, double* %1
br i1 %10, label %12, label %24
12: ; preds = %0, %12
%13 = phi double [ %18, %12 ], [ %11, %0 ]
%14 = call double @f1(double %13)
%15 = load double, double* %1
%16 = call double @fd1(double %15)
%17 = fdiv double %14, %16
%18 = fsub double %13, %17
%19 = load double, double* %1
%20 = fsub double %18, %19
%21 = call double @llvm.fabs.f64(double %20)
store double %18, double* %1
%22 = load double, double* %2
%23 = fcmp ogt double %21, %22
br i1 %23, label %12, label %24
24: ; preds = %12, %0
%25 = phi double [ %11, %0 ], [ %18, %12 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), double %25)
ret i32 0
}