#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*/ printf(char *, int, double, char *);
main() {
  double pid, s1, s2, s3, s4;
  double series(int m, int n);
  void ihex(double x, int m, char c[]);
  int id = 0;
  char chx[16];
  s1 = series(1, id);
  s2 = series(4, id);
  s3 = series(5, id);
  s4 = series(6, id);
  pid = 4. * s1 - 2. * s2 - s3 - s4;
  pid = pid - (int)pid + 1.;
  ihex(pid, 16, chx);
  printf(" position = %i\n fraction = %.15f \n hex digits =  %10.10s\n", id,
         pid, chx);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
mov    $0x1,%edi
call   1030 <series@plt>
movsd  %xmm0,-0x10(%rbp)
mov    -0x2c(%rbp),%esi
mov    $0x4,%edi
call   1030 <series@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x2c(%rbp),%esi
mov    $0x5,%edi
call   1030 <series@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x2c(%rbp),%esi
mov    $0x6,%edi
call   1030 <series@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe7c(%rip),%xmm1
mulsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xe50(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
subsd  -0x20(%rbp),%xmm0
subsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
cvttsd2si -0x8(%rbp),%eax
cvtsi2sd %eax,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe17(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
lea    -0x40(%rbp),%rsi
mov    $0x10,%edi
call   1050 <ihex@plt>
mov    -0x2c(%rbp),%esi
movsd  -0x8(%rbp),%xmm0
lea    -0x40(%rbp),%rdx
lea    0xe00(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x30,%rsp
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <series@plt>
movapd %xmm0,(%rsp)
mov    $0x4,%edi
xor    %esi,%esi
call   1030 <series@plt>
movsd  %xmm0,0x18(%rsp)
mov    $0x5,%edi
xor    %esi,%esi
call   1030 <series@plt>
movsd  %xmm0,0x10(%rsp)
mov    $0x6,%edi
xor    %esi,%esi
call   1030 <series@plt>
movapd (%rsp),%xmm1
mulsd  0xe7d(%rip),%xmm1
movsd  0x18(%rsp),%xmm2
addsd  %xmm2,%xmm2
subsd  %xmm2,%xmm1
subsd  0x10(%rsp),%xmm1
subsd  %xmm0,%xmm1
cvttpd2dq %xmm1,%xmm0
cvtdq2pd %xmm0,%xmm0
subsd  %xmm0,%xmm1
addsd  0xe59(%rip),%xmm1
movapd %xmm1,(%rsp)
lea    0x20(%rsp),%rbx
movapd %xmm1,%xmm0
mov    $0x10,%edi
mov    %rbx,%rsi
call   1050 <ihex@plt>
lea    0xe3f(%rip),%rdi
xor    %esi,%esi
movaps (%rsp),%xmm0
mov    %rbx,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [58 x i8] c" position = %i\0A fraction = %.15f \0A hex digits = %10.10s\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
%7 = alloca [16 x i8]
store i32 0, i32* %6
%8 = load i32, i32* %6
%9 = call double @series(i32 1, i32 %8)
store double %9, double* %2
%10 = load i32, i32* %6
%11 = call double @series(i32 4, i32 %10)
store double %11, double* %3
%12 = load i32, i32* %6
%13 = call double @series(i32 5, i32 %12)
store double %13, double* %4
%14 = load i32, i32* %6
%15 = call double @series(i32 6, i32 %14)
store double %15, double* %5
%16 = load double, double* %2
%17 = load double, double* %3
%18 = fmul double 2.000000e+00, %17
%19 = fneg double %18
%20 = call double @llvm.fmuladd.f64(double 4.000000e+00, double %16, double %19)
%21 = load double, double* %4
%22 = fsub double %20, %21
%23 = load double, double* %5
%24 = fsub double %22, %23
store double %24, double* %1
%25 = load double, double* %1
%26 = load double, double* %1
%27 = fptosi double %26 to i32
%28 = sitofp i32 %27 to double
%29 = fsub double %25, %28
%30 = fadd double %29, 1.000000e+00
store double %30, double* %1
%31 = load double, double* %1
%32 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%33 = load i32, i32* %6
%34 = load double, double* %1
%35 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%36 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 %33, double %34, i8* %35)
ret i32 0
}

LLVM IR (-O2):
@.str = [58 x i8] c" position = %i\0A fraction = %.15f \0A hex digits = %10.10s\0A\00"
define i32 @main() {
%1 = alloca [16 x i8]
%2 = getelementptr inbounds [16 x i8], [16 x i8]* %1, i64 0, i64 0
%3 = tail call double @series(i32 1, i32 0)
%4 = tail call double @series(i32 4, i32 0)
%5 = tail call double @series(i32 5, i32 0)
%6 = tail call double @series(i32 6, i32 0)
%7 = fmul double %4, -2.000000e+00
%8 = tail call double @llvm.fmuladd.f64(double %3, double 4.000000e+00, double %7)
%9 = fsub double %8, %5
%10 = fsub double %9, %6
%11 = fptosi double %10 to i32
%12 = sitofp i32 %11 to double
%13 = fsub double %10, %12
%14 = fadd double %13, 1.000000e+00
%15 = call i32 @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0), i32 0, double %14, i8* %2)
ret i32 0
}