#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 fabs(double);
double cfrac(double n, double x) {
  int i;
  double a, b, c, d, e, f;
  b = x + 1 - n;
  c = 1 / (2.2204460492503131e-16 * 2.2204460492503131e-16 *
           2.2204460492503131e-16);
  f = d = 1 / b;
  for (i = 1; i < 1024; i++) {
    a = i * (n - i);
    d = a * d + (b += 2);
    if (fabs(d) < (2.2204460492503131e-16 * 2.2204460492503131e-16 *
                   2.2204460492503131e-16))
      d = (2.2204460492503131e-16 * 2.2204460492503131e-16 *
           2.2204460492503131e-16);
    c = b + a / c;
    if (fabs(c) < (2.2204460492503131e-16 * 2.2204460492503131e-16 *
                   2.2204460492503131e-16))
      c = (2.2204460492503131e-16 * 2.2204460492503131e-16 *
           2.2204460492503131e-16);
    d = 1 / d;
    f *= e = d * c;
    if (fabs(e - 1) < 2.2204460492503131e-16)
      break;
  }
  return f;
}


x86 assembly (clang, -O0):
<cfrac>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  0xeea(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xedb(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xec6(%rip),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  %xmm0,-0x48(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x400,-0x14(%rbp)
jge    1289 <cfrac+0x189>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
cvtsi2sdl -0x14(%rbp),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  0xe8d(%rip),%xmm1
addsd  -0x28(%rbp),%xmm1
movsd  %xmm1,-0x28(%rbp)
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
movaps 0xe82(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe56(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d1 <cfrac+0xd1>
movsd  0xe44(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
divsd  -0x30(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm1
movaps 0xe3b(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe0f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1218 <cfrac+0x118>
movsd  0xdfd(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xde0(%rip),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mulsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x40(%rbp),%xmm1
movsd  0xdb0(%rip),%xmm0
subsd  %xmm0,%xmm1
movaps 0xdd5(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xdb9(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1276 <cfrac+0x176>
jmp    1289 <cfrac+0x189>
jmp    127b <cfrac+0x17b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1150 <cfrac+0x50>
movsd  -0x48(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfrac>:
movsd  0xef7(%rip),%xmm8
addsd  %xmm8,%xmm1
subsd  %xmm0,%xmm1
movapd %xmm8,%xmm6
divsd  %xmm1,%xmm6
movsd  0xee4(%rip),%xmm10
mov    $0x1,%eax
movsd  0xede(%rip),%xmm9
movapd 0xef5(%rip),%xmm14
movsd  0xed5(%rip),%xmm7
movsd  0xed4(%rip),%xmm11
movapd 0xedb(%rip),%xmm12
movsd  0xeca(%rip),%xmm13
movapd %xmm6,%xmm5
movapd %xmm10,%xmm3
nopw   0x0(%rax,%rax,1)
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
movapd %xmm0,%xmm4
subsd  %xmm2,%xmm4
mulsd  %xmm2,%xmm4
addsd  %xmm9,%xmm1
mulsd  %xmm4,%xmm5
movapd %xmm5,%xmm2
addsd  %xmm1,%xmm2
movapd %xmm2,%xmm5
andpd  %xmm14,%xmm5
ucomisd %xmm5,%xmm7
movapd %xmm10,%xmm5
ja     11b1 <cfrac+0xb1>
movapd %xmm8,%xmm5
divsd  %xmm2,%xmm5
divsd  %xmm3,%xmm4
addsd  %xmm1,%xmm4
movapd %xmm4,%xmm3
andpd  %xmm14,%xmm3
cmpltsd %xmm7,%xmm3
movapd %xmm3,%xmm2
andnpd %xmm4,%xmm2
andpd  %xmm7,%xmm3
orpd   %xmm2,%xmm3
movapd %xmm5,%xmm2
mulsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm6
addsd  %xmm11,%xmm2
andpd  %xmm12,%xmm2
ucomisd %xmm2,%xmm13
ja     1204 <cfrac+0x104>
lea    0x1(%rax),%ecx
cmp    $0x3ff,%eax
mov    %ecx,%eax
jne    1170 <cfrac+0x70>
movapd %xmm6,%xmm0
ret

LLVM IR (-O0):
define double @cfrac(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %3
store double %1, double* %4
%12 = load double, double* %4
%13 = fadd double %12, 1.000000e+00
%14 = load double, double* %3
%15 = fsub double %13, %14
store double %15, double* %7
store double 0x49B0000000000000, double* %8
%16 = load double, double* %7
%17 = fdiv double 1.000000e+00, %16
store double %17, double* %9
store double %17, double* %11
store i32 1, i32* %5
br label %18
18: ; preds = %62, %2
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 1024
br i1 %20, label %21, label %65
21: ; preds = %18
%22 = load i32, i32* %5
%23 = sitofp i32 %22 to double
%24 = load double, double* %3
%25 = load i32, i32* %5
%26 = sitofp i32 %25 to double
%27 = fsub double %24, %26
%28 = fmul double %23, %27
store double %28, double* %6
%29 = load double, double* %6
%30 = load double, double* %9
%31 = load double, double* %7
%32 = fadd double %31, 2.000000e+00
store double %32, double* %7
%33 = call double @llvm.fmuladd.f64(double %29, double %30, double %32)
store double %33, double* %9
%34 = load double, double* %9
%35 = call double @llvm.fabs.f64(double %34)
%36 = fcmp olt double %35, 0x3630000000000000
br i1 %36, label %37, label %38
37: ; preds = %21
store double 0x3630000000000000, double* %9
br label %38
38: ; preds = %37, %21
%39 = load double, double* %7
%40 = load double, double* %6
%41 = load double, double* %8
%42 = fdiv double %40, %41
%43 = fadd double %39, %42
store double %43, double* %8
%44 = load double, double* %8
%45 = call double @llvm.fabs.f64(double %44)
%46 = fcmp olt double %45, 0x3630000000000000
br i1 %46, label %47, label %48
47: ; preds = %38
store double 0x3630000000000000, double* %8
br label %48
48: ; preds = %47, %38
%49 = load double, double* %9
%50 = fdiv double 1.000000e+00, %49
store double %50, double* %9
%51 = load double, double* %9
%52 = load double, double* %8
%53 = fmul double %51, %52
store double %53, double* %10
%54 = load double, double* %11
%55 = fmul double %54, %53
store double %55, double* %11
%56 = load double, double* %10
%57 = fsub double %56, 1.000000e+00
%58 = call double @llvm.fabs.f64(double %57)
%59 = fcmp olt double %58, 0x3CB0000000000000
br i1 %59, label %60, label %61
60: ; preds = %48
br label %65
61: ; preds = %48
br label %62
62: ; preds = %61
%63 = load i32, i32* %5
%64 = add nsw i32 %63, 1
store i32 %64, i32* %5
br label %18
65: ; preds = %60, %18
%66 = load double, double* %11
ret double %66
}

LLVM IR (-O2):
define double @cfrac(double %0, double %1) {
%3 = fadd double %1, 1.000000e+00
%4 = fsub double %3, %0
%5 = fdiv double 1.000000e+00, %4
br label %6
6: ; preds = %6, %2
%7 = phi double [ %5, %2 ], [ %27, %6 ]
%8 = phi i32 [ 1, %2 ], [ %31, %6 ]
%9 = phi double [ %5, %2 ], [ %25, %6 ]
%10 = phi double [ 0x49B0000000000000, %2 ], [ %23, %6 ]
%11 = phi double [ %4, %2 ], [ %15, %6 ]
%12 = sitofp i32 %8 to double
%13 = fsub double %0, %12
%14 = fmul double %13, %12
%15 = fadd double %11, 2.000000e+00
%16 = tail call double @llvm.fmuladd.f64(double %14, double %9, double %15)
%17 = tail call double @llvm.fabs.f64(double %16)
%18 = fcmp olt double %17, 0x3630000000000000
%19 = fdiv double %14, %10
%20 = fadd double %15, %19
%21 = tail call double @llvm.fabs.f64(double %20)
%22 = fcmp olt double %21, 0x3630000000000000
%23 = select i1 %22, double 0x3630000000000000, double %20
%24 = fdiv double 1.000000e+00, %16
%25 = select i1 %18, double 0x49B0000000000000, double %24
%26 = fmul double %25, %23
%27 = fmul double %7, %26
%28 = fadd double %26, -1.000000e+00
%29 = tail call double @llvm.fabs.f64(double %28)
%30 = fcmp olt double %29, 0x3CB0000000000000
%31 = add nuw nsw i32 %8, 1
%32 = icmp eq i32 %31, 1024
%33 = select i1 %30, i1 true, i1 %32
br i1 %33, label %34, label %6
34: ; preds = %6
ret double %27
}