#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 series(double n, double x) {
  int i;
  double t, sum;
  sum = t = 1 / n;
  for (i = 1024; --i >= 0;) {
    sum += t *= x / ++n;
    if (fabs(t) < fabs(sum) * 2.2204460492503131e-16)
      break;
  }
  return sum;
}


x86 assembly (clang, -O0):
<series>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  0xeea(%rip),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  %xmm0,-0x28(%rbp)
movl   $0x400,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jl     11ad <series+0xad>
movsd  -0x10(%rbp),%xmm0
movsd  0xeb5(%rip),%xmm1
addsd  -0x8(%rbp),%xmm1
movsd  %xmm1,-0x8(%rbp)
divsd  %xmm1,%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
movaps 0xe97(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  -0x28(%rbp),%xmm0
movaps 0xe87(%rip),%xmm2
pand   %xmm2,%xmm0
movsd  0xe73(%rip),%xmm2
mulsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
jbe    11a8 <series+0xa8>
jmp    11ad <series+0xad>
jmp    112c <series+0x2c>
movsd  -0x28(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<series>:
movsd  0xef7(%rip),%xmm8
movapd %xmm8,%xmm4
divsd  %xmm0,%xmm4
mov    $0xfffffbff,%eax
movapd 0xef1(%rip),%xmm5
movsd  0xee1(%rip),%xmm6
movapd %xmm4,%xmm3
nopl   0x0(%rax,%rax,1)
inc    %eax
je     1163 <series+0x63>
addsd  %xmm8,%xmm0
movapd %xmm1,%xmm7
divsd  %xmm0,%xmm7
mulsd  %xmm7,%xmm4
addsd  %xmm4,%xmm3
movapd %xmm4,%xmm7
andpd  %xmm5,%xmm7
movapd %xmm3,%xmm2
andpd  %xmm5,%xmm2
mulsd  %xmm6,%xmm2
ucomisd %xmm7,%xmm2
jbe    1130 <series+0x30>
movapd %xmm3,%xmm0
ret

LLVM IR (-O0):
define double @series(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store double %1, double* %4
%8 = load double, double* %3
%9 = fdiv double 1.000000e+00, %8
store double %9, double* %6
store double %9, double* %7
store i32 1024, i32* %5
br label %10
10: ; preds = %30, %2
%11 = load i32, i32* %5
%12 = add nsw i32 %11, -1
store i32 %12, i32* %5
%13 = icmp sge i32 %12, 0
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = load double, double* %4
%16 = load double, double* %3
%17 = fadd double %16, 1.000000e+00
store double %17, double* %3
%18 = fdiv double %15, %17
%19 = load double, double* %6
%20 = fmul double %19, %18
store double %20, double* %6
%21 = load double, double* %7
%22 = fadd double %21, %20
store double %22, double* %7
%23 = load double, double* %6
%24 = call double @llvm.fabs.f64(double %23)
%25 = load double, double* %7
%26 = call double @llvm.fabs.f64(double %25)
%27 = fmul double %26, 0x3CB0000000000000
%28 = fcmp olt double %24, %27
br i1 %28, label %29, label %30
29: ; preds = %14
br label %31
30: ; preds = %14
br label %10
31: ; preds = %29, %10
%32 = load double, double* %7
ret double %32
}

LLVM IR (-O2):
define double @series(double %0, double %1) {
%3 = fdiv double 1.000000e+00, %0
br label %4
4: ; preds = %10, %2
%5 = phi double [ %0, %2 ], [ %12, %10 ]
%6 = phi i32 [ 1024, %2 ], [ %11, %10 ]
%7 = phi double [ %3, %2 ], [ %14, %10 ]
%8 = phi double [ %3, %2 ], [ %15, %10 ]
%9 = icmp eq i32 %6, 0
br i1 %9, label %20, label %10
10: ; preds = %4
%11 = add nsw i32 %6, -1
%12 = fadd double %5, 1.000000e+00
%13 = fdiv double %1, %12
%14 = fmul double %7, %13
%15 = fadd double %8, %14
%16 = tail call double @llvm.fabs.f64(double %14)
%17 = tail call double @llvm.fabs.f64(double %15)
%18 = fmul double %17, 0x3CB0000000000000
%19 = fcmp olt double %16, %18
br i1 %19, label %20, label %4
20: ; preds = %10, %4
%21 = phi double [ %15, %10 ], [ %8, %4 ]
ret double %21
}