#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 df(double);
double f(double);
double fabs(double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  double x0;
  double x1;
  double eps = 1e-6;
  double Dx;
  int i = 0;
  printf("x0: ");
  scanf("%d", &x0);
  do {
    x1 = x0 - f(x0) / df(x0);
    Dx = fabs(x1 - x0);
    x0 = x1;
    i++;
  } while (Dx > eps);
  printf("%f\n", x1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <scanf@plt>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <f@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1060 <df@plt>
movsd  -0x40(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x38(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movaps 0xe41(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x20(%rbp),%xmm0
ja     1181 <main+0x41>
movsd  -0x18(%rbp),%xmm0
lea    0xe21(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xecd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
movsd  (%rsp),%xmm1
cs nopw 0x0(%rax,%rax,1)
movsd  %xmm1,0x10(%rsp)
movapd %xmm1,%xmm0
call   1030 <f@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1060 <df@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
divsd  %xmm0,%xmm2
subsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
subsd  (%rsp),%xmm0
andpd  0xe4c(%rip),%xmm0
movsd  %xmm1,(%rsp)
ucomisd 0xe4f(%rip),%xmm0
ja     1170 <main+0x30>
lea    0xe56(%rip),%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"x0: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store i32 0, i32* %1
store double 0x3EB0C6F7A0B5ED8D, double* %4
store i32 0, i32* %6
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double* %2)
br label %9
9: ; preds = %24, %0
%10 = load double, double* %2
%11 = load double, double* %2
%12 = call double @f(double %11)
%13 = load double, double* %2
%14 = call double @df(double %13)
%15 = fdiv double %12, %14
%16 = fsub double %10, %15
store double %16, double* %3
%17 = load double, double* %3
%18 = load double, double* %2
%19 = fsub double %17, %18
%20 = call double @llvm.fabs.f64(double %19)
store double %20, double* %5
%21 = load double, double* %3
store double %21, double* %2
%22 = load i32, i32* %6
%23 = add nsw i32 %22, 1
store i32 %23, i32* %6
br label %24
24: ; preds = %9
%25 = load double, double* %5
%26 = load double, double* %4
%27 = fcmp ogt double %25, %26
br i1 %27, label %9, label %28
28: ; preds = %24
%29 = load double, double* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %29)
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [5 x i8] c"x0: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%f\0A\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), double* %1)
%5 = load double, double* %1
br label %6
6: ; preds = %6, %0
%7 = phi double [ %12, %6 ], [ %5, %0 ]
%8 = call double @f(double %7)
%9 = load double, double* %1
%10 = call double @df(double %9)
%11 = fdiv double %8, %10
%12 = fsub double %7, %11
%13 = load double, double* %1
%14 = fsub double %12, %13
%15 = call double @llvm.fabs.f64(double %14)
store double %12, double* %1
%16 = fcmp ogt double %15, 0x3EB0C6F7A0B5ED8D
br i1 %16, label %6, label %17
17: ; preds = %6
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), double %12)
ret i32 0
}