#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 cos(double);
double fabs(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 > 0) {
    x1 = cos(x0);
    cota = fabs(x1 - x0);
    printf("x0: %lf, x1: %lf, cota: %lf\n", x0, x1, cota);
    x0 = x1;
  }
  printf("Tomá: %lf\n", x0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <scanf@plt>
movsd  0xe7d(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11ef <main+0xbf>
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xe56(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
lea    0xe70(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    1188 <main+0x58>
movsd  -0x10(%rbp),%xmm0
lea    0xe6b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
lea    0xedc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeda(%rip),%rbx
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
lea    0xecc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x28(%rsp),%rsi
mov    %rbx,%rdi
call   1040 <scanf@plt>
movsd  (%rsp),%xmm0
lea    0xec5(%rip),%rbx
nopl   0x0(%rax)
call   1050 <cos@plt>
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
movapd %xmm1,%xmm2
subsd  %xmm0,%xmm2
movapd %xmm2,0x10(%rsp)
andpd  0xe56(%rip),%xmm2
mov    %rbx,%rdi
mov    $0x3,%al
call   1030 <printf@plt>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movapd 0x10(%rsp),%xmm1
ucomisd 0xe43(%rip),%xmm1
jne    1180 <main+0x50>
lea    0xe88(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%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 = [29 x i8] c"x0: %lf, x1: %lf, cota: %lf\0A\00"
@.str.4 = [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 = %13, %0
%11 = load double, double* %4
%12 = fcmp ogt double %11, 0.000000e+00
br i1 %12, label %13, label %25
13: ; preds = %10
%14 = load double, double* %2
%15 = call double @cos(double %14)
store double %15, double* %3
%16 = load double, double* %3
%17 = load double, double* %2
%18 = fsub double %16, %17
%19 = call double @llvm.fabs.f64(double %18)
store double %19, double* %4
%20 = load double, double* %2
%21 = load double, double* %3
%22 = load double, double* %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), double %20, double %21, double %22)
%24 = load double, double* %3
store double %24, double* %2
br label %10
25: ; preds = %10
%26 = load double, double* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %26)
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 = [29 x i8] c"x0: %lf, x1: %lf, cota: %lf\0A\00"
@.str.4 = [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* %1
br label %10
10: ; preds = %0, %10
%11 = phi double [ %9, %0 ], [ %12, %10 ]
%12 = call double @cos(double %11)
%13 = load double, double* %1
%14 = fsub double %12, %13
%15 = call double @llvm.fabs.f64(double %14)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), double %13, double %12, double %15)
store double %12, double* %1
%17 = fcmp ueq double %14, 0.000000e+00
br i1 %17, label %18, label %10
18: ; preds = %10
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0), double %12)
ret i32 0
}