#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 deriv(double, double);
double fun(double, double, double);
double next(double, double, double);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
main() {
  double x_in, n, c, x_nxt, i, tm;
  printf("Please enter the value of c\n");
  scanf("%lf", &c);
  printf("Please enter the value of n\n");
  scanf("%lf", &n);
  x_in = c / 2;
  x_nxt = x_in - fun(x_in, n, c) / deriv(x_in, n);
  for (i = 0; i < 100000; i++) {
    x_nxt = next(x_nxt, n, c);
  }
  printf("The root of the funcation is %f\n", x_nxt);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1060 <scanf@plt>
movsd  -0x20(%rbp),%xmm0
movsd  0xe58(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1030 <fun@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
call   1070 <deriv@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xdfb(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1248 <main+0xf8>
movsd  -0x28(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
call   1050 <next@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  0xdd7(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1205 <main+0xb5>
movsd  -0x28(%rbp),%xmm0
lea    0xe02(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xec1(%rip),%rdi
call   1030 <puts@plt>
lea    0xe90(%rip),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
lea    0xebd(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%rsi
mov    %rbx,%rdi
call   1070 <scanf@plt>
movsd  0x10(%rsp),%xmm2
movsd  0xe56(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm1
call   1040 <fun@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm1
movsd  0x8(%rsp),%xmm0
call   1080 <deriv@plt>
movsd  0x18(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
subsd  %xmm1,%xmm0
mov    $0x186a0,%ebx
nopl   (%rax)
movsd  (%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
call   1060 <next@plt>
add    $0xffffffff,%ebx
jne    11f0 <main+0x90>
lea    0xe00(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Please enter the value of c\0A\00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [29 x i8] c"Please enter the value of n\0A\00"
@.str.3 = [33 x i8] c"The root of the funcation is %f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 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* %4)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %3)
%12 = load double, double* %4
%13 = fdiv double %12, 2.000000e+00
store double %13, double* %2
%14 = load double, double* %2
%15 = load double, double* %2
%16 = load double, double* %3
%17 = load double, double* %4
%18 = call double @fun(double %15, double %16, double %17)
%19 = load double, double* %2
%20 = load double, double* %3
%21 = call double @deriv(double %19, double %20)
%22 = fdiv double %18, %21
%23 = fsub double %14, %22
store double %23, double* %5
store double 0.000000e+00, double* %6
br label %24
24: ; preds = %32, %0
%25 = load double, double* %6
%26 = fcmp olt double %25, 1.000000e+05
br i1 %26, label %27, label %35
27: ; preds = %24
%28 = load double, double* %5
%29 = load double, double* %3
%30 = load double, double* %4
%31 = call double @next(double %28, double %29, double %30)
store double %31, double* %5
br label %32
32: ; preds = %27
%33 = load double, double* %6
%34 = fadd double %33, 1.000000e+00
store double %34, double* %6
br label %24
35: ; preds = %24
%36 = load double, double* %5
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %36)
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@.str.1 = [4 x i8] c"%lf\00"
@.str.3 = [33 x i8] c"The root of the funcation is %f\0A\00"
@str = [28 x i8] c"Please enter the value of c\00"
@str.4 = [28 x i8] c"Please enter the value of n\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 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 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* %2)
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.4, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %1)
%9 = load double, double* %2
%10 = fmul double %9, 5.000000e-01
%11 = load double, double* %1
%12 = call double @fun(double %10, double %11, double %9)
%13 = load double, double* %1
%14 = call double @deriv(double %10, double %13)
%15 = fdiv double %12, %14
%16 = fsub double %10, %15
br label %17
17: ; preds = %0, %17
%18 = phi double [ %16, %0 ], [ %22, %17 ]
%19 = phi i32 [ 0, %0 ], [ %23, %17 ]
%20 = load double, double* %1
%21 = load double, double* %2
%22 = call double @next(double %18, double %20, double %21)
%23 = add nuw nsw i32 %19, 1
%24 = icmp eq i32 %23, 100000
br i1 %24, label %25, label %17
25: ; preds = %17
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), double %22)
ret i32 0
}