#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 */
int fabs(double);
double fn(double, int);
int /*<<< orphan*/ printf(char *, int, double);
main() {
  double x[2], x_guess[2], x0;
  double epsilon, delta;
  int N, i, k, j;
  double f, g;
  delta = 0.0000001;
  N = 100;
  for (k = 1; k <= 10; k++) {
    x_guess[0] =
        (2 * k - 1) * 3.1415926535897932384626433832795 / 2. + 0.0000001;
    x_guess[1] =
        (2 * k + 1) * 3.1415926535897932384626433832795 / 2. - 0.0000001;
    for (j = 0; j < 2; j++) {
      x[j] = x_guess[j];
      x0 = x_guess[j];
      for (i = 1; i <= N; i++) {
        f = fn(x[j], k);
        g = (fn(x[j] + fn(x[j], k), k) - fn(x[j], k)) / fn(x[j], k);
        x[j] = x[j] - f / g;
        epsilon = fabs(x[j] - x0);
        x0 = x[j];
        if (epsilon < delta)
          i = N + 1;
      }
    }
    if (fabs(x[0]) < 10000000.) {
      printf("The solution for k=%i is x=%.10f  \n", k, x[0]);
    } else
      printf("The solution for k=%i is x=%.10f  \n", k, x[1]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movsd  0xeb6(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x64,-0x4c(%rbp)
movl   $0x1,-0x54(%rbp)
cmpl   $0xa,-0x54(%rbp)
jg     13a2 <main+0x272>
mov    -0x54(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe94(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe80(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe6c(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x54(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe5e(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xe4a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe36(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x58(%rbp)
cmpl   $0x2,-0x58(%rbp)
jge    1342 <main+0x212>
movslq -0x58(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm0
movslq -0x58(%rbp),%rax
movsd  %xmm0,-0x20(%rbp,%rax,8)
movslq -0x58(%rbp),%rax
movsd  -0x30(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x1,-0x50(%rbp)
mov    -0x50(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jg     132f <main+0x1ff>
movslq -0x58(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
mov    -0x54(%rbp),%edi
call   1030 <fn@plt>
movsd  %xmm0,-0x60(%rbp)
movslq -0x58(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x80(%rbp)
movslq -0x58(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
mov    -0x54(%rbp),%edi
call   1030 <fn@plt>
movaps %xmm0,%xmm1
movsd  -0x80(%rbp),%xmm0
addsd  %xmm1,%xmm0
mov    -0x54(%rbp),%edi
call   1030 <fn@plt>
movsd  %xmm0,-0x78(%rbp)
movslq -0x58(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
mov    -0x54(%rbp),%edi
call   1030 <fn@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movslq -0x58(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
mov    -0x54(%rbp),%edi
call   1030 <fn@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movslq -0x58(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
movsd  -0x60(%rbp),%xmm1
divsd  -0x68(%rbp),%xmm1
subsd  %xmm1,%xmm0
movslq -0x58(%rbp),%rax
movsd  %xmm0,-0x20(%rbp,%rax,8)
movslq -0x58(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1050 <fabs@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
movslq -0x58(%rbp),%rax
movsd  -0x20(%rbp,%rax,8),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    131c <main+0x1ec>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1321 <main+0x1f1>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    120e <main+0xde>
jmp    1334 <main+0x204>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    11da <main+0xaa>
movsd  -0x20(%rbp),%xmm0
call   1050 <fabs@plt>
cvtsi2sd %eax,%xmm1
movsd  0xcc0(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    137b <main+0x24b>
mov    -0x54(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
lea    0xcaf(%rip),%rdi
call   1040 <printf@plt>
jmp    138f <main+0x25f>
mov    -0x54(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
lea    0xc96(%rip),%rdi
call   1040 <printf@plt>
jmp    1394 <main+0x264>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    115d <main+0x2d>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    $0x1,%ebx
mov    $0x66,%r15d
lea    0xed4(%rip),%r14
jmp    1166 <main+0x36>
xchg   %ax,%ax
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
add    $0x1,%ebx
cmp    $0xb,%ebx
je     1335 <main+0x205>
lea    (%rbx,%rbx,1),%eax
add    $0xffffffff,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movsd  0xe85(%rip),%xmm0
mulsd  %xmm0,%xmm2
movsd  0xe81(%rip),%xmm1
mulsd  %xmm1,%xmm2
addsd  0xe7d(%rip),%xmm2
movsd  %xmm2,0x10(%rsp)
lea    0x1(%rbx,%rbx,1),%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm1,%xmm2
addsd  0xe64(%rip),%xmm2
movsd  %xmm2,0x18(%rsp)
mov    $0x1,%ebp
nop
movsd  0x10(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   1030 <fn@plt>
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1030 <fn@plt>
addsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1030 <fn@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1030 <fn@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1030 <fn@plt>
movsd  0x8(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  0x20(%rsp),%xmm1
divsd  %xmm2,%xmm1
movsd  0x10(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
subsd  (%rsp),%xmm0
call   1050 <fabs@plt>
add    $0x1,%ebp
test   %eax,%eax
cmovle %r15d,%ebp
cmp    $0x65,%ebp
jl     11c0 <main+0x90>
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsd  0x18(%rsp),%xmm0
movsd  %xmm0,(%rsp)
mov    %ebx,%edi
call   1030 <fn@plt>
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1030 <fn@plt>
addsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1030 <fn@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1030 <fn@plt>
movsd  0x8(%rsp),%xmm1
subsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  (%rsp),%xmm0
mov    %ebx,%edi
call   1030 <fn@plt>
movsd  0x8(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  0x20(%rsp),%xmm1
divsd  %xmm2,%xmm1
movsd  0x18(%rsp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%rsp)
subsd  (%rsp),%xmm0
call   1050 <fabs@plt>
add    $0x1,%ebp
test   %eax,%eax
cmovle %r15d,%ebp
cmp    $0x65,%ebp
jl     1270 <main+0x140>
movsd  0x10(%rsp),%xmm0
call   1050 <fabs@plt>
movsd  0x10(%rsp),%xmm0
cmp    $0x989680,%eax
jl     1150 <main+0x20>
movsd  0x18(%rsp),%xmm0
jmp    1150 <main+0x20>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"The solution for k=%i is x=%.10f \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x double]
%3 = alloca [2 x double]
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca double
store i32 0, i32* %1
store double 0x3E7AD7F29ABCAF48, double* %6
store i32 100, i32* %7
store i32 1, i32* %9
br label %13
13: ; preds = %140, %0
%14 = load i32, i32* %9
%15 = icmp sle i32 %14, 10
br i1 %15, label %16, label %143
16: ; preds = %13
%17 = load i32, i32* %9
%18 = mul nsw i32 2, %17
%19 = sub nsw i32 %18, 1
%20 = sitofp i32 %19 to double
%21 = fmul double %20, 0x400921FB54442D18
%22 = fdiv double %21, 2.000000e+00
%23 = fadd double %22, 0x3E7AD7F29ABCAF48
%24 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 0
store double %23, double* %24
%25 = load i32, i32* %9
%26 = mul nsw i32 2, %25
%27 = add nsw i32 %26, 1
%28 = sitofp i32 %27 to double
%29 = fmul double %28, 0x400921FB54442D18
%30 = fdiv double %29, 2.000000e+00
%31 = fsub double %30, 0x3E7AD7F29ABCAF48
%32 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 1
store double %31, double* %32
store i32 0, i32* %10
br label %33
33: ; preds = %120, %16
%34 = load i32, i32* %10
%35 = icmp slt i32 %34, 2
br i1 %35, label %36, label %123
36: ; preds = %33
%37 = load i32, i32* %10
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 %38
%40 = load double, double* %39
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %42
store double %40, double* %43
%44 = load i32, i32* %10
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [2 x double], [2 x double]* %3, i64 0, i64 %45
%47 = load double, double* %46
store double %47, double* %4
store i32 1, i32* %8
br label %48
48: ; preds = %116, %36
%49 = load i32, i32* %8
%50 = load i32, i32* %7
%51 = icmp sle i32 %49, %50
br i1 %51, label %52, label %119
52: ; preds = %48
%53 = load i32, i32* %10
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %54
%56 = load double, double* %55
%57 = load i32, i32* %9
%58 = call double @fn(double %56, i32 %57)
store double %58, double* %11
%59 = load i32, i32* %10
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %60
%62 = load double, double* %61
%63 = load i32, i32* %10
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %64
%66 = load double, double* %65
%67 = load i32, i32* %9
%68 = call double @fn(double %66, i32 %67)
%69 = fadd double %62, %68
%70 = load i32, i32* %9
%71 = call double @fn(double %69, i32 %70)
%72 = load i32, i32* %10
%73 = sext i32 %72 to i64
%74 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %73
%75 = load double, double* %74
%76 = load i32, i32* %9
%77 = call double @fn(double %75, i32 %76)
%78 = fsub double %71, %77
%79 = load i32, i32* %10
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %80
%82 = load double, double* %81
%83 = load i32, i32* %9
%84 = call double @fn(double %82, i32 %83)
%85 = fdiv double %78, %84
store double %85, double* %12
%86 = load i32, i32* %10
%87 = sext i32 %86 to i64
%88 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %87
%89 = load double, double* %88
%90 = load double, double* %11
%91 = load double, double* %12
%92 = fdiv double %90, %91
%93 = fsub double %89, %92
%94 = load i32, i32* %10
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %95
store double %93, double* %96
%97 = load i32, i32* %10
%98 = sext i32 %97 to i64
%99 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %98
%100 = load double, double* %99
%101 = load double, double* %4
%102 = fsub double %100, %101
%103 = call i32 @fabs(double %102)
%104 = sitofp i32 %103 to double
store double %104, double* %5
%105 = load i32, i32* %10
%106 = sext i32 %105 to i64
%107 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 %106
%108 = load double, double* %107
store double %108, double* %4
%109 = load double, double* %5
%110 = load double, double* %6
%111 = fcmp olt double %109, %110
br i1 %111, label %112, label %115
112: ; preds = %52
%113 = load i32, i32* %7
%114 = add nsw i32 %113, 1
store i32 %114, i32* %8
br label %115
115: ; preds = %112, %52
br label %116
116: ; preds = %115
%117 = load i32, i32* %8
%118 = add nsw i32 %117, 1
store i32 %118, i32* %8
br label %48
119: ; preds = %48
br label %120
120: ; preds = %119
%121 = load i32, i32* %10
%122 = add nsw i32 %121, 1
store i32 %122, i32* %10
br label %33
123: ; preds = %33
%124 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 0
%125 = load double, double* %124
%126 = call i32 @fabs(double %125)
%127 = sitofp i32 %126 to double
%128 = fcmp olt double %127, 1.000000e+07
br i1 %128, label %129, label %134
129: ; preds = %123
%130 = load i32, i32* %9
%131 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 0
%132 = load double, double* %131
%133 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %130, double %132)
br label %139
134: ; preds = %123
%135 = load i32, i32* %9
%136 = getelementptr inbounds [2 x double], [2 x double]* %2, i64 0, i64 1
%137 = load double, double* %136
%138 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %135, double %137)
br label %139
139: ; preds = %134, %129
br label %140
140: ; preds = %139
%141 = load i32, i32* %9
%142 = add nsw i32 %141, 1
store i32 %142, i32* %9
br label %13
143: ; preds = %13
%144 = load i32, i32* %1
ret i32 %144
}

LLVM IR (-O2):
@.str = [36 x i8] c"The solution for k=%i is x=%.10f \0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %52
%2 = phi i32 [ 1, %0 ], [ %57, %52 ]
%3 = shl nuw nsw i32 %2, 1
%4 = add nsw i32 %3, -1
%5 = sitofp i32 %4 to double
%6 = fmul double %5, 0x400921FB54442D18
%7 = fmul double %6, 5.000000e-01
%8 = fadd double %7, 0x3E7AD7F29ABCAF48
%9 = or i32 %3, 1
%10 = sitofp i32 %9 to double
%11 = fmul double %10, 0x400921FB54442D18
%12 = fmul double %11, 5.000000e-01
%13 = fadd double %12, 0xBE7AD7F29ABCAF48
br label %14
14: ; preds = %1, %14
%15 = phi i32 [ 1, %1 ], [ %31, %14 ]
%16 = phi double [ %8, %1 ], [ %26, %14 ]
%17 = tail call double @fn(double %16, i32 %2)
%18 = tail call double @fn(double %16, i32 %2)
%19 = fadd double %16, %18
%20 = tail call double @fn(double %19, i32 %2)
%21 = tail call double @fn(double %16, i32 %2)
%22 = fsub double %20, %21
%23 = tail call double @fn(double %16, i32 %2)
%24 = fdiv double %22, %23
%25 = fdiv double %17, %24
%26 = fsub double %16, %25
%27 = fsub double %26, %16
%28 = tail call i32 @fabs(double %27)
%29 = icmp slt i32 %28, 1
%30 = add nsw i32 %15, 1
%31 = select i1 %29, i32 102, i32 %30
%32 = icmp slt i32 %31, 101
br i1 %32, label %14, label %33
33: ; preds = %14, %33
%34 = phi i32 [ %50, %33 ], [ 1, %14 ]
%35 = phi double [ %45, %33 ], [ %13, %14 ]
%36 = tail call double @fn(double %35, i32 %2)
%37 = tail call double @fn(double %35, i32 %2)
%38 = fadd double %35, %37
%39 = tail call double @fn(double %38, i32 %2)
%40 = tail call double @fn(double %35, i32 %2)
%41 = fsub double %39, %40
%42 = tail call double @fn(double %35, i32 %2)
%43 = fdiv double %41, %42
%44 = fdiv double %36, %43
%45 = fsub double %35, %44
%46 = fsub double %45, %35
%47 = tail call i32 @fabs(double %46)
%48 = icmp slt i32 %47, 1
%49 = add nsw i32 %34, 1
%50 = select i1 %48, i32 102, i32 %49
%51 = icmp slt i32 %50, 101
br i1 %51, label %33, label %52
52: ; preds = %33
%53 = tail call i32 @fabs(double %26)
%54 = icmp slt i32 %53, 10000000
%55 = select i1 %54, double %26, double %45
%56 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %2, double %55)
%57 = add nuw nsw i32 %2, 1
%58 = icmp eq i32 %57, 11
br i1 %58, label %59, label %1
59: ; preds = %52
ret i32 0
}