#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 */
scalar_t__ malloc(int);
int pow(int, int);
void *bpp(void *arg) {
  int k = *(int *)arg;
  double sum = (4.0 / (8 * k + 1)) - (2.0 / (8 * k + 4)) - (1.0 / (8 * k + 5)) -
               (1.0 / (8 * k + 6));
  double *product = (double *)malloc(sizeof(double));
  if (product) {
    *product = 1 / pow(16, k) * sum;
  }
  return (void *)product;
}


x86 assembly (clang, -O0):
<bpp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xec6(%rip),%xmm0
divsd  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
add    $0x4,%eax
cvtsi2sd %eax,%xmm2
movsd  0xea5(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
add    $0x5,%eax
cvtsi2sd %eax,%xmm2
movsd  0xe80(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
mov    -0xc(%rbp),%eax
shl    $0x3,%eax
add    $0x6,%eax
cvtsi2sd %eax,%xmm2
movsd  0xe63(%rip),%xmm1
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11eb <bpp+0xcb>
mov    -0xc(%rbp),%esi
mov    $0x10,%edi
call   1040 <pow@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
mulsd  -0x18(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bpp>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%r14d
mov    $0x8,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
je     11d5 <bpp+0xb5>
lea    0x0(,%r14,8),%eax
mov    %eax,%ecx
or     $0x1,%ecx
cvtsi2sd %ecx,%xmm0
movsd  0xeaa(%rip),%xmm1
divsd  %xmm0,%xmm1
mov    %eax,%ecx
or     $0x4,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  0xe9a(%rip),%xmm3
divsd  %xmm0,%xmm3
addsd  %xmm1,%xmm3
mov    %eax,%ecx
or     $0x5,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  0xe86(%rip),%xmm1
movapd %xmm1,%xmm2
divsd  %xmm0,%xmm2
subsd  %xmm2,%xmm3
or     $0x6,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  %xmm0,%xmm1
subsd  %xmm1,%xmm3
movsd  %xmm3,(%rsp)
mov    $0x10,%edi
mov    %r14d,%esi
call   1040 <pow@plt>
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
cmovb  %eax,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @bpp(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca double
%5 = alloca double*
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = bitcast i8* %6 to i32*
%8 = load i32, i32* %7
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = mul nsw i32 8, %9
%11 = add nsw i32 %10, 1
%12 = sitofp i32 %11 to double
%13 = fdiv double 4.000000e+00, %12
%14 = load i32, i32* %3
%15 = mul nsw i32 8, %14
%16 = add nsw i32 %15, 4
%17 = sitofp i32 %16 to double
%18 = fdiv double 2.000000e+00, %17
%19 = fsub double %13, %18
%20 = load i32, i32* %3
%21 = mul nsw i32 8, %20
%22 = add nsw i32 %21, 5
%23 = sitofp i32 %22 to double
%24 = fdiv double 1.000000e+00, %23
%25 = fsub double %19, %24
%26 = load i32, i32* %3
%27 = mul nsw i32 8, %26
%28 = add nsw i32 %27, 6
%29 = sitofp i32 %28 to double
%30 = fdiv double 1.000000e+00, %29
%31 = fsub double %25, %30
store double %31, double* %4
%32 = call i64 @malloc(i32 8)
%33 = inttoptr i64 %32 to double*
store double* %33, double** %5
%34 = load double*, double** %5
%35 = icmp ne double* %34, null
br i1 %35, label %36, label %44
36: ; preds = %1
%37 = load i32, i32* %3
%38 = call i32 @pow(i32 16, i32 %37)
%39 = sdiv i32 1, %38
%40 = sitofp i32 %39 to double
%41 = load double, double* %4
%42 = fmul double %40, %41
%43 = load double*, double** %5
store double %42, double* %43
br label %44
44: ; preds = %36, %1
%45 = load double*, double** %5
%46 = bitcast double* %45 to i8*
ret i8* %46
}

LLVM IR (-O2):
define i8* @bpp(i8* nocapture %0) {
%2 = bitcast i8* %0 to i32*
%3 = load i32, i32* %2
%4 = shl nsw i32 %3, 3
%5 = tail call i64 @malloc(i32 8)
%6 = icmp eq i64 %5, 0
br i1 %6, label %30, label %7
7: ; preds = %1
%8 = inttoptr i64 %5 to double*
%9 = or i32 %4, 1
%10 = sitofp i32 %9 to double
%11 = fdiv double 4.000000e+00, %10
%12 = or i32 %4, 4
%13 = sitofp i32 %12 to double
%14 = fdiv double 2.000000e+00, %13
%15 = fsub double %11, %14
%16 = or i32 %4, 5
%17 = sitofp i32 %16 to double
%18 = fdiv double 1.000000e+00, %17
%19 = fsub double %15, %18
%20 = or i32 %4, 6
%21 = sitofp i32 %20 to double
%22 = fdiv double 1.000000e+00, %21
%23 = fsub double %19, %22
%24 = tail call i32 @pow(i32 16, i32 %3)
%25 = add i32 %24, 1
%26 = icmp ult i32 %25, 3
%27 = select i1 %26, i32 %24, i32 0
%28 = sitofp i32 %27 to double
%29 = fmul double %23, %28
store double %29, double* %8
br label %30
30: ; preds = %7, %1
%31 = inttoptr i64 %5 to i8*
ret i8* %31
}