#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 deriv1(double *, int, int, double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
double function(double *, int, int, double);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ system(char *);
double newton(double *param, int dimension, int functiontype, double precision,
              double *error, long int *inter, double extr_a, double extr_b,
              int mode) {
  int interations = 0;
  int i = 0;
  double root = 0.0;
  system("clear");
  fprintf(stdout, "Input The Requested Number Of Iterations : ");
  scanf("%i", &interations);
  double X[interations];
  double funz[interations];
  double der[interations];
  system("clear");
  fprintf(stdout, "Calculating ...\n");
  switch (mode) {
  case 1: {
    X[0] = extr_b;
    funz[0] = function(param, dimension, functiontype, X[0]);
    der[0] = deriv1(param, dimension, functiontype, X[0]);
    for (i = 1; i <= interations; i++) {
      fprintf(stdout, "%i / %i", i, interations);
      funz[i] = function(param, dimension, functiontype, X[i]);
      der[i] = deriv1(param, dimension, functiontype, X[i]);
      X[i] = X[0] - (funz[i - 1] / der[i - 1]);
    }
    root = X[interations];
    break;
  }
  case 2: {
    X[0] = extr_a;
    funz[0] = function(param, dimension, functiontype, X[0]);
    der[0] = deriv1(param, dimension, functiontype, X[0]);
    for (i = 1; i <= interations; i++) {
      fprintf(stdout, "%i / %i", i, interations);
      funz[i] = function(param, dimension, functiontype, X[i]);
      der[i] = deriv1(param, dimension, functiontype, X[i]);
      X[i] = X[0] - (funz[i - 1] / der[i - 1]);
    }
    root = X[interations];
    break;
  }
  }
  return root;
}


x86 assembly (clang, -O0):
<newton>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movsd  %xmm0,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
movsd  %xmm1,-0x30(%rbp)
movsd  %xmm2,-0x38(%rbp)
mov    %r9d,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movq   $0x0,-0x50(%rbp)
lea    0xe63(%rip),%rdi
mov    %rdi,-0xa0(%rbp)
call   1030 <system@plt>
mov    0x2e30(%rip),%rax
mov    %rax,-0x80(%rbp)
mov    (%rax),%edi
lea    0xe49(%rip),%rsi
xor    %eax,%eax
mov    %al,-0x75(%rbp)
call   1040 <fprintf@plt>
lea    0xe7a(%rip),%rdi
lea    -0x40(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0xa0(%rbp),%rdi
mov    -0x40(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x58(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x98(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x60(%rbp)
mov    -0x40(%rbp),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x68(%rbp)
mov    -0x40(%rbp),%eax
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x70(%rbp)
call   1030 <system@plt>
mov    -0x80(%rbp),%rcx
mov    -0x75(%rbp),%al
mov    (%rcx),%edi
lea    0xdcf(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x74(%rbp)
sub    $0x1,%eax
je     128d <newton+0x13d>
jmp    127c <newton+0x12c>
mov    -0x74(%rbp),%eax
sub    $0x2,%eax
je     13d1 <newton+0x281>
jmp    1510 <newton+0x3c0>
mov    -0x98(%rbp),%rax
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movsd  (%rax),%xmm0
call   1070 <function@plt>
mov    -0x90(%rbp),%rcx
mov    -0x98(%rbp),%rax
movsd  %xmm0,(%rcx)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movsd  (%rax),%xmm0
call   1050 <deriv1@plt>
mov    -0x88(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x40(%rbp),%eax
jg     13b7 <newton+0x267>
mov    0x2ce6(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
mov    -0x40(%rbp),%ecx
lea    0xd3a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x98(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1070 <function@plt>
mov    -0x90(%rbp),%rcx
mov    -0x98(%rbp),%rax
movslq -0x44(%rbp),%rdx
movsd  %xmm0,(%rcx,%rdx,8)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1050 <deriv1@plt>
mov    -0x90(%rbp),%rdx
mov    -0x88(%rbp),%rcx
mov    -0x98(%rbp),%rax
movslq -0x44(%rbp),%rsi
movsd  %xmm0,(%rcx,%rsi,8)
movsd  (%rax),%xmm0
mov    -0x44(%rbp),%esi
sub    $0x1,%esi
movslq %esi,%rsi
movsd  (%rdx,%rsi,8),%xmm1
mov    -0x44(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
divsd  (%rcx,%rdx,8),%xmm1
subsd  %xmm1,%xmm0
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    12e7 <newton+0x197>
mov    -0x98(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    1510 <newton+0x3c0>
mov    -0x98(%rbp),%rax
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movsd  (%rax),%xmm0
call   1070 <function@plt>
mov    -0x90(%rbp),%rcx
mov    -0x98(%rbp),%rax
movsd  %xmm0,(%rcx)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movsd  (%rax),%xmm0
call   1050 <deriv1@plt>
mov    -0x88(%rbp),%rax
movsd  %xmm0,(%rax)
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x40(%rbp),%eax
jg     14fb <newton+0x3ab>
mov    0x2ba2(%rip),%rax
mov    (%rax),%edi
mov    -0x44(%rbp),%edx
mov    -0x40(%rbp),%ecx
lea    0xbf6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x98(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1070 <function@plt>
mov    -0x90(%rbp),%rcx
mov    -0x98(%rbp),%rax
movslq -0x44(%rbp),%rdx
movsd  %xmm0,(%rcx,%rdx,8)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
movslq -0x44(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
call   1050 <deriv1@plt>
mov    -0x90(%rbp),%rdx
mov    -0x88(%rbp),%rcx
mov    -0x98(%rbp),%rax
movslq -0x44(%rbp),%rsi
movsd  %xmm0,(%rcx,%rsi,8)
movsd  (%rax),%xmm0
mov    -0x44(%rbp),%esi
sub    $0x1,%esi
movslq %esi,%rsi
movsd  (%rdx,%rsi,8),%xmm1
mov    -0x44(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
divsd  (%rcx,%rdx,8),%xmm1
subsd  %xmm1,%xmm0
movslq -0x44(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    142b <newton+0x2db>
mov    -0x98(%rbp),%rax
movslq -0x40(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
mov    -0x58(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newton>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9d,-0x38(%rbp)
movsd  %xmm2,-0x48(%rbp)
movsd  %xmm1,-0x40(%rbp)
mov    %edx,%r14d
mov    %esi,%r15d
mov    %rdi,%r13
movl   $0x0,-0x2c(%rbp)
lea    0xe7a(%rip),%rdi
call   1030 <system@plt>
mov    0x2e4e(%rip),%rbx
mov    (%rbx),%edi
lea    0xe6b(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
lea    0xe9f(%rip),%rdi
lea    -0x2c(%rbp),%rsi
call   1060 <scanf@plt>
mov    %rsp,-0x60(%rbp)
mov    -0x2c(%rbp),%eax
mov    %rsp,%r12
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
lea    0xe2b(%rip),%rdi
call   1030 <system@plt>
mov    (%rbx),%edi
lea    0xe4f(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    -0x38(%rbp),%eax
cmp    $0x2,%eax
je     12cd <newton+0x17d>
xorps  %xmm0,%xmm0
cmp    $0x1,%eax
jne    13a1 <newton+0x251>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,(%r12)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1070 <function@plt>
movsd  %xmm0,-0x38(%rbp)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
movsd  -0x48(%rbp),%xmm0
call   1050 <deriv1@plt>
mov    -0x2c(%rbp),%ecx
test   %ecx,%ecx
jle    1398 <newton+0x248>
mov    $0x1,%ebx
movsd  -0x38(%rbp),%xmm1
nopl   0x0(%rax,%rax,1)
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x38(%rbp)
mov    0x2d80(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
movsd  (%r12,%rbx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1070 <function@plt>
movsd  %xmm0,-0x58(%rbp)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
movsd  -0x50(%rbp),%xmm0
call   1050 <deriv1@plt>
movsd  -0x48(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
movsd  %xmm1,(%r12,%rbx,8)
lea    0x1(%rbx),%rax
movslq -0x2c(%rbp),%rcx
movsd  -0x58(%rbp),%xmm1
cmp    %rcx,%rbx
mov    %rax,%rbx
jl     1250 <newton+0x100>
jmp    1398 <newton+0x248>
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,(%r12)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1070 <function@plt>
movsd  %xmm0,-0x38(%rbp)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
movsd  -0x40(%rbp),%xmm0
call   1050 <deriv1@plt>
mov    -0x2c(%rbp),%ecx
test   %ecx,%ecx
jle    1398 <newton+0x248>
mov    $0x1,%ebx
movsd  -0x38(%rbp),%xmm1
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x38(%rbp)
mov    0x2cb0(%rip),%rax
mov    (%rax),%edi
lea    0xd0a(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <fprintf@plt>
movsd  (%r12,%rbx,8),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
call   1070 <function@plt>
movsd  %xmm0,-0x58(%rbp)
mov    %r13,%rdi
mov    %r15d,%esi
mov    %r14d,%edx
movsd  -0x50(%rbp),%xmm0
call   1050 <deriv1@plt>
movsd  -0x40(%rbp),%xmm1
subsd  -0x38(%rbp),%xmm1
movsd  %xmm1,(%r12,%rbx,8)
lea    0x1(%rbx),%rax
movslq -0x2c(%rbp),%rcx
movsd  -0x58(%rbp),%xmm1
cmp    %rcx,%rbx
mov    %rax,%rbx
jl     1320 <newton+0x1d0>
movslq %ecx,%rax
movsd  (%r12,%rax,8),%xmm0
mov    -0x60(%rbp),%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"clear\00"
@stdout = global i32 0
@.str.1 = [44 x i8] c"Input The Requested Number Of Iterations : \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [17 x i8] c"Calculating ...\0A\00"
@.str.4 = [8 x i8] c"%i / %i\00"
define double @newton(double* %0, i32 %1, i32 %2, double %3, double* %4, i64* %5, double %6, double %7, i32 %8) {
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double*
%15 = alloca i64*
%16 = alloca double
%17 = alloca double
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca double
%22 = alloca i8*
%23 = alloca i64
%24 = alloca i64
%25 = alloca i64
store double* %0, double** %10
store i32 %1, i32* %11
store i32 %2, i32* %12
store double %3, double* %13
store double* %4, double** %14
store i64* %5, i64** %15
store double %6, double* %16
store double %7, double* %17
store i32 %8, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store double 0.000000e+00, double* %21
%26 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%27 = load i32, i32* @stdout
%28 = call i32 (i32, i8*, ...) @fprintf(i32 %27, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %19)
%30 = load i32, i32* %19
%31 = zext i32 %30 to i64
%32 = call i8* @llvm.stacksave()
store i8* %32, i8** %22
%33 = alloca double, i64 %31
store i64 %31, i64* %23
%34 = load i32, i32* %19
%35 = zext i32 %34 to i64
%36 = alloca double, i64 %35
store i64 %35, i64* %24
%37 = load i32, i32* %19
%38 = zext i32 %37 to i64
%39 = alloca double, i64 %38
store i64 %38, i64* %25
%40 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%41 = load i32, i32* @stdout
%42 = call i32 (i32, i8*, ...) @fprintf(i32 %41, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%43 = load i32, i32* %18
switch i32 %43, label %190 [
i32 1, label %44
i32 2, label %117
]
44: ; preds = %9
%45 = load double, double* %17
%46 = getelementptr inbounds double, double* %33, i64 0
store double %45, double* %46
%47 = load double*, double** %10
%48 = load i32, i32* %11
%49 = load i32, i32* %12
%50 = getelementptr inbounds double, double* %33, i64 0
%51 = load double, double* %50
%52 = call double @function(double* %47, i32 %48, i32 %49, double %51)
%53 = getelementptr inbounds double, double* %36, i64 0
store double %52, double* %53
%54 = load double*, double** %10
%55 = load i32, i32* %11
%56 = load i32, i32* %12
%57 = getelementptr inbounds double, double* %33, i64 0
%58 = load double, double* %57
%59 = call double @deriv1(double* %54, i32 %55, i32 %56, double %58)
%60 = getelementptr inbounds double, double* %39, i64 0
store double %59, double* %60
store i32 1, i32* %20
br label %61
61: ; preds = %109, %44
%62 = load i32, i32* %20
%63 = load i32, i32* %19
%64 = icmp sle i32 %62, %63
br i1 %64, label %65, label %112
65: ; preds = %61
%66 = load i32, i32* @stdout
%67 = load i32, i32* %20
%68 = load i32, i32* %19
%69 = call i32 (i32, i8*, ...) @fprintf(i32 %66, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %67, i32 %68)
%70 = load double*, double** %10
%71 = load i32, i32* %11
%72 = load i32, i32* %12
%73 = load i32, i32* %20
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds double, double* %33, i64 %74
%76 = load double, double* %75
%77 = call double @function(double* %70, i32 %71, i32 %72, double %76)
%78 = load i32, i32* %20
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds double, double* %36, i64 %79
store double %77, double* %80
%81 = load double*, double** %10
%82 = load i32, i32* %11
%83 = load i32, i32* %12
%84 = load i32, i32* %20
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds double, double* %33, i64 %85
%87 = load double, double* %86
%88 = call double @deriv1(double* %81, i32 %82, i32 %83, double %87)
%89 = load i32, i32* %20
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds double, double* %39, i64 %90
store double %88, double* %91
%92 = getelementptr inbounds double, double* %33, i64 0
%93 = load double, double* %92
%94 = load i32, i32* %20
%95 = sub nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds double, double* %36, i64 %96
%98 = load double, double* %97
%99 = load i32, i32* %20
%100 = sub nsw i32 %99, 1
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds double, double* %39, i64 %101
%103 = load double, double* %102
%104 = fdiv double %98, %103
%105 = fsub double %93, %104
%106 = load i32, i32* %20
%107 = sext i32 %106 to i64
%108 = getelementptr inbounds double, double* %33, i64 %107
store double %105, double* %108
br label %109
109: ; preds = %65
%110 = load i32, i32* %20
%111 = add nsw i32 %110, 1
store i32 %111, i32* %20
br label %61
112: ; preds = %61
%113 = load i32, i32* %19
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds double, double* %33, i64 %114
%116 = load double, double* %115
store double %116, double* %21
br label %190
117: ; preds = %9
%118 = load double, double* %16
%119 = getelementptr inbounds double, double* %33, i64 0
store double %118, double* %119
%120 = load double*, double** %10
%121 = load i32, i32* %11
%122 = load i32, i32* %12
%123 = getelementptr inbounds double, double* %33, i64 0
%124 = load double, double* %123
%125 = call double @function(double* %120, i32 %121, i32 %122, double %124)
%126 = getelementptr inbounds double, double* %36, i64 0
store double %125, double* %126
%127 = load double*, double** %10
%128 = load i32, i32* %11
%129 = load i32, i32* %12
%130 = getelementptr inbounds double, double* %33, i64 0
%131 = load double, double* %130
%132 = call double @deriv1(double* %127, i32 %128, i32 %129, double %131)
%133 = getelementptr inbounds double, double* %39, i64 0
store double %132, double* %133
store i32 1, i32* %20
br label %134
134: ; preds = %182, %117
%135 = load i32, i32* %20
%136 = load i32, i32* %19
%137 = icmp sle i32 %135, %136
br i1 %137, label %138, label %185
138: ; preds = %134
%139 = load i32, i32* @stdout
%140 = load i32, i32* %20
%141 = load i32, i32* %19
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %140, i32 %141)
%143 = load double*, double** %10
%144 = load i32, i32* %11
%145 = load i32, i32* %12
%146 = load i32, i32* %20
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds double, double* %33, i64 %147
%149 = load double, double* %148
%150 = call double @function(double* %143, i32 %144, i32 %145, double %149)
%151 = load i32, i32* %20
%152 = sext i32 %151 to i64
%153 = getelementptr inbounds double, double* %36, i64 %152
store double %150, double* %153
%154 = load double*, double** %10
%155 = load i32, i32* %11
%156 = load i32, i32* %12
%157 = load i32, i32* %20
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds double, double* %33, i64 %158
%160 = load double, double* %159
%161 = call double @deriv1(double* %154, i32 %155, i32 %156, double %160)
%162 = load i32, i32* %20
%163 = sext i32 %162 to i64
%164 = getelementptr inbounds double, double* %39, i64 %163
store double %161, double* %164
%165 = getelementptr inbounds double, double* %33, i64 0
%166 = load double, double* %165
%167 = load i32, i32* %20
%168 = sub nsw i32 %167, 1
%169 = sext i32 %168 to i64
%170 = getelementptr inbounds double, double* %36, i64 %169
%171 = load double, double* %170
%172 = load i32, i32* %20
%173 = sub nsw i32 %172, 1
%174 = sext i32 %173 to i64
%175 = getelementptr inbounds double, double* %39, i64 %174
%176 = load double, double* %175
%177 = fdiv double %171, %176
%178 = fsub double %166, %177
%179 = load i32, i32* %20
%180 = sext i32 %179 to i64
%181 = getelementptr inbounds double, double* %33, i64 %180
store double %178, double* %181
br label %182
182: ; preds = %138
%183 = load i32, i32* %20
%184 = add nsw i32 %183, 1
store i32 %184, i32* %20
br label %134
185: ; preds = %134
%186 = load i32, i32* %19
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds double, double* %33, i64 %187
%189 = load double, double* %188
store double %189, double* %21
br label %190
190: ; preds = %9, %185, %112
%191 = load double, double* %21
%192 = load i8*, i8** %22
ret double %191
}

LLVM IR (-O2):
@.str = [6 x i8] c"clear\00"
@stdout = global i32 0
@.str.1 = [44 x i8] c"Input The Requested Number Of Iterations : \00"
@.str.2 = [3 x i8] c"%i\00"
@.str.3 = [17 x i8] c"Calculating ...\0A\00"
@.str.4 = [8 x i8] c"%i / %i\00"
define double @newton(double* %0, i32 %1, i32 %2, double %3, double* nocapture readnone %4, i64* nocapture readnone %5, double %6, double %7, i32 %8) {
%10 = alloca i32
%11 = bitcast i32* %10 to i8*
store i32 0, i32* %10
%12 = tail call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%13 = load i32, i32* @stdout
%14 = tail call i32 (i32, i8*, ...) @fprintf(i32 %13, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%16 = load i32, i32* %10
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
%19 = alloca double, i64 %17
%20 = call i32 @system(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* @stdout
%22 = call i32 (i32, i8*, ...) @fprintf(i32 %21, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
switch i32 %8, label %74 [
i32 1, label %23
i32 2, label %46
]
23: ; preds = %9
store double %7, double* %19
%24 = call double @function(double* %0, i32 %1, i32 %2, double %7)
%25 = call double @deriv1(double* %0, i32 %1, i32 %2, double %7)
%26 = load i32, i32* %10
%27 = icmp slt i32 %26, 1
br i1 %27, label %69, label %28
28: ; preds = %23, %28
%29 = phi double [ %39, %28 ], [ %25, %23 ]
%30 = phi double [ %38, %28 ], [ %24, %23 ]
%31 = phi i64 [ %42, %28 ], [ 1, %23 ]
%32 = phi i32 [ %43, %28 ], [ %26, %23 ]
%33 = load i32, i32* @stdout
%34 = trunc i64 %31 to i32
%35 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %34, i32 %32)
%36 = getelementptr inbounds double, double* %19, i64 %31
%37 = load double, double* %36
%38 = call double @function(double* %0, i32 %1, i32 %2, double %37)
%39 = call double @deriv1(double* %0, i32 %1, i32 %2, double %37)
%40 = fdiv double %30, %29
%41 = fsub double %7, %40
store double %41, double* %36
%42 = add nuw nsw i64 %31, 1
%43 = load i32, i32* %10
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %31, %44
br i1 %45, label %28, label %69
46: ; preds = %9
store double %6, double* %19
%47 = call double @function(double* %0, i32 %1, i32 %2, double %6)
%48 = call double @deriv1(double* %0, i32 %1, i32 %2, double %6)
%49 = load i32, i32* %10
%50 = icmp slt i32 %49, 1
br i1 %50, label %69, label %51
51: ; preds = %46, %51
%52 = phi double [ %62, %51 ], [ %48, %46 ]
%53 = phi double [ %61, %51 ], [ %47, %46 ]
%54 = phi i64 [ %65, %51 ], [ 1, %46 ]
%55 = phi i32 [ %66, %51 ], [ %49, %46 ]
%56 = load i32, i32* @stdout
%57 = trunc i64 %54 to i32
%58 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %57, i32 %55)
%59 = getelementptr inbounds double, double* %19, i64 %54
%60 = load double, double* %59
%61 = call double @function(double* %0, i32 %1, i32 %2, double %60)
%62 = call double @deriv1(double* %0, i32 %1, i32 %2, double %60)
%63 = fdiv double %53, %52
%64 = fsub double %6, %63
store double %64, double* %59
%65 = add nuw nsw i64 %54, 1
%66 = load i32, i32* %10
%67 = sext i32 %66 to i64
%68 = icmp slt i64 %54, %67
br i1 %68, label %51, label %69
69: ; preds = %51, %28, %46, %23
%70 = phi i32 [ %26, %23 ], [ %49, %46 ], [ %43, %28 ], [ %66, %51 ]
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds double, double* %19, i64 %71
%73 = load double, double* %72
br label %74
74: ; preds = %69, %9
%75 = phi double [ 0.000000e+00, %9 ], [ %73, %69 ]
ret double %75
}