#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, long double);
int /*<<< orphan*/ stderr;
long strtol(char *, int /*<<< orphan*/ *, int);
int main(int argc, char **argv) {
  long int n;
  if (argc != 3) {
    fprintf(stderr, "usage: LeibnizPi1G <fromidx> <toidx_uninclusive>\n");
    exit(EXIT_FAILURE);
  }
  long int loop_from = strtol(argv[1], NULL, 10);
  long int loop_to = strtol(argv[2], NULL, 10);
  long double pisum = 0.0L;
  const long double one = 1.0L;
  const long double four = 4.0L;
  for (n = loop_from; n < loop_to; ++n)
    pisum += (one / (four * n + one)) - (one / (four * n - one));
  long double LeibnizPi = 4.0 * (1.0 + pisum);
  printf("%.20Lf\n", LeibnizPi);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1186 <main+0x46>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    %rsi,-0x88(%rbp)
mov    $0xa,%edx
mov    %edx,-0x7c(%rbp)
call   1050 <strtol@plt>
mov    -0x88(%rbp),%rsi
mov    -0x7c(%rbp),%edx
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <strtol@plt>
mov    %rax,-0x28(%rbp)
fldz
fstpt  -0x40(%rbp)
fld1
fstpt  -0x50(%rbp)
flds   0xe2b(%rip)
fstpt  -0x60(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    122c <main+0xec>
mov    -0x18(%rbp),%rax
mov    %rax,-0x78(%rbp)
fildll -0x78(%rbp)
flds   0xe01(%rip)
fmulp  %st,%st(1)
fld1
fld    %st(1)
fadd   %st(1),%st
fdivr  %st(1),%st
fxch   %st(1)
fchs
fadd   %st,%st(2)
fdivp  %st,%st(2)
faddp  %st,%st(1)
fldt   -0x40(%rbp)
faddp  %st,%st(1)
fstpt  -0x40(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11e0 <main+0xa0>
fldt   -0x40(%rbp)
fld1
faddp  %st,%st(1)
flds   0xdc7(%rip)
fmulp  %st,%st(1)
fstpt  -0x70(%rbp)
fldt   -0x70(%rbp)
mov    %rsp,%rax
fstpt  (%rax)
lea    0xde9(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    11db <main+0x9b>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %rax,%rbx
mov    0x10(%r14),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1050 <strtol@plt>
flds   0xe84(%rip)
cmp    %rax,%rbx
jge    11c2 <main+0x82>
fstp   %st(0)
fldz
fld1
fld    %st(0)
fchs
nopl   0x0(%rax,%rax,1)
mov    %rbx,0x10(%rsp)
fildll 0x10(%rsp)
fmuls  0xe61(%rip)
fld    %st(0)
fadd   %st(3),%st
fdivr  %st(3),%st
fxch   %st(1)
fadd   %st(2),%st
fdivr  %st(2),%st
faddp  %st,%st(1)
faddp  %st,%st(3)
add    $0x1,%rbx
cmp    %rbx,%rax
jne    1190 <main+0x50>
fstp   %st(0)
faddp  %st,%st(1)
fmuls  0xe3e(%rip)
fstpt  (%rsp)
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
lea    0xe19(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [50 x i8] c"usage: LeibnizPi1G <fromidx> <toidx_uninclusive>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"%.20Lf\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca x86_fp80
%10 = alloca x86_fp80
%11 = alloca x86_fp80
%12 = alloca x86_fp80
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 3
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i64 @strtol(i8* %23, i32* null, i32 10)
store i64 %24, i64* %7
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 2
%27 = load i8*, i8** %26
%28 = call i64 @strtol(i8* %27, i32* null, i32 10)
store i64 %28, i64* %8
store x86_fp80 0xK00000000000000000000, x86_fp80* %9
store x86_fp80 0xK3FFF8000000000000000, x86_fp80* %10
store x86_fp80 0xK40018000000000000000, x86_fp80* %11
%29 = load i64, i64* %7
store i64 %29, i64* %6
br label %30
30: ; preds = %46, %20
%31 = load i64, i64* %6
%32 = load i64, i64* %8
%33 = icmp slt i64 %31, %32
br i1 %33, label %34, label %49
34: ; preds = %30
%35 = load i64, i64* %6
%36 = sitofp i64 %35 to x86_fp80
%37 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40018000000000000000, x86_fp80 %36, x86_fp80 0xK3FFF8000000000000000)
%38 = fdiv x86_fp80 0xK3FFF8000000000000000, %37
%39 = load i64, i64* %6
%40 = sitofp i64 %39 to x86_fp80
%41 = call x86_fp80 @llvm.fmuladd.f80(x86_fp80 0xK40018000000000000000, x86_fp80 %40, x86_fp80 0xKBFFF8000000000000000)
%42 = fdiv x86_fp80 0xK3FFF8000000000000000, %41
%43 = fsub x86_fp80 %38, %42
%44 = load x86_fp80, x86_fp80* %9
%45 = fadd x86_fp80 %44, %43
store x86_fp80 %45, x86_fp80* %9
br label %46
46: ; preds = %34
%47 = load i64, i64* %6
%48 = add nsw i64 %47, 1
store i64 %48, i64* %6
br label %30
49: ; preds = %30
%50 = load x86_fp80, x86_fp80* %9
%51 = fadd x86_fp80 0xK3FFF8000000000000000, %50
%52 = fmul x86_fp80 0xK40018000000000000000, %51
store x86_fp80 %52, x86_fp80* %12
%53 = load x86_fp80, x86_fp80* %12
%54 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %53)
%55 = load i32, i32* %3
ret i32 %55
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [50 x i8] c"usage: LeibnizPi1G <fromidx> <toidx_uninclusive>\0A\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [8 x i8] c"%.20Lf\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %9, label %4
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @EXIT_FAILURE
%8 = tail call i32 @exit(i32 %7)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i64 @strtol(i8* nocapture %11, i32* null, i32 10)
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i64 @strtol(i8* nocapture %14, i32* null, i32 10)
%16 = icmp slt i64 %12, %15
br i1 %16, label %17, label %32
17: ; preds = %9, %17
%18 = phi i64 [ %27, %17 ], [ %12, %9 ]
%19 = phi x86_fp80 [ %26, %17 ], [ 0xK00000000000000000000, %9 ]
%20 = sitofp i64 %18 to x86_fp80
%21 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %20, x86_fp80 0xK40018000000000000000, x86_fp80 0xK3FFF8000000000000000)
%22 = fdiv x86_fp80 0xK3FFF8000000000000000, %21
%23 = tail call x86_fp80 @llvm.fmuladd.f80(x86_fp80 %20, x86_fp80 0xK40018000000000000000, x86_fp80 0xKBFFF8000000000000000)
%24 = fdiv x86_fp80 0xK3FFF8000000000000000, %23
%25 = fsub x86_fp80 %22, %24
%26 = fadd x86_fp80 %19, %25
%27 = add nsw i64 %18, 1
%28 = icmp eq i64 %27, %15
br i1 %28, label %29, label %17
29: ; preds = %17
%30 = fadd x86_fp80 %26, 0xK3FFF8000000000000000
%31 = fmul x86_fp80 %30, 0xK40018000000000000000
br label %32
32: ; preds = %29, %9
%33 = phi x86_fp80 [ 0xK40018000000000000000, %9 ], [ %31, %29 ]
%34 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), x86_fp80 %33)
ret i32 0
}