#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 M_PI;
int exp(double);
double ell_mod(double Kratio) {
  double q, nom = 1, denom = 0;
  int m = 1;
  q = exp(-M_PI * Kratio);
  while (exp(-M_PI * Kratio * (double)(m * m - 2 * m + 1)) > 1e-15 && m < 50) {
    denom += 2 * exp(-M_PI * Kratio * ((double)m - 0.5) * ((double)m - 0.5));
    nom += 2 * exp(-M_PI * Kratio * (double)(m * m));
    m++;
  }
  q = (denom / nom);
  return q * q;
}


x86 assembly (clang, -O0):
<ell_mod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xedb(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
mov    0x2ea8(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x8(%rbp),%xmm0
call   1030 <exp@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0x2e73(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x8(%rbp),%xmm0
mov    -0x24(%rbp),%eax
imul   -0x24(%rbp),%eax
mov    -0x24(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
cvtsi2sd %eax,%xmm0
xor    %eax,%eax
movsd  0xe46(%rip),%xmm1
ucomisd %xmm1,%xmm0
mov    %al,-0x25(%rbp)
jbe    11d9 <ell_mod+0xc9>
cmpl   $0x32,-0x24(%rbp)
setl   %al
mov    %al,-0x25(%rbp)
mov    -0x25(%rbp),%al
test   $0x1,%al
jne    11e9 <ell_mod+0xd9>
jmp    12aa <ell_mod+0x19a>
mov    0x2df8(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xdf3(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
movsd  0xdde(%rip),%xmm2
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2d91(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  -0x8(%rbp),%xmm0
mov    -0x24(%rbp),%eax
imul   -0x24(%rbp),%eax
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    116e <ell_mod+0x5e>
movsd  -0x20(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ell_mod>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movapd %xmm0,%xmm1
movsd  %xmm0,0x8(%rsp)
mov    0x2eb9(%rip),%r14
movsd  (%r14),%xmm0
xorpd  0xec4(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movsd  (%r14),%xmm0
xorpd  0xeae(%rip),%xmm0
mulsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
xorpd  %xmm0,%xmm0
test   %eax,%eax
jle    126a <ell_mod+0x15a>
xorpd  %xmm0,%xmm0
movhpd 0xe93(%rip),%xmm0
mov    $0x1,%ebp
mov    $0xfffffffc,%r13d
mov    $0x1,%r12d
xchg   %ax,%ax
movapd %xmm0,0x10(%rsp)
movsd  (%r14),%xmm0
movapd 0xe5d(%rip),%xmm1
xorpd  %xmm1,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %r12d,%xmm1
mulsd  0x8(%rsp),%xmm0
addsd  0xe5b(%rip),%xmm1
mulsd  %xmm1,%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
mov    %eax,%r15d
movsd  (%r14),%xmm1
xorpd  0xe26(%rip),%xmm1
mulsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movd   %r15d,%xmm0
movd   %eax,%xmm1
punpckldq %xmm1,%xmm0
paddd  %xmm0,%xmm0
cvtdq2pd %xmm0,%xmm0
addpd  0x10(%rsp),%xmm0
movapd %xmm0,0x10(%rsp)
lea    0x1(%r12),%ebx
movsd  (%r14),%xmm1
xorpd  0xddd(%rip),%xmm1
mulsd  0x8(%rsp),%xmm1
mov    %ebx,%ebp
imul   %ebp,%ebp
lea    0x1(%rbp,%r13,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm1,%xmm0
call   1030 <exp@plt>
movapd 0x10(%rsp),%xmm0
test   %eax,%eax
jle    125e <ell_mod+0x14e>
add    $0xfffffffe,%r13d
cmp    $0x31,%r12d
mov    %ebx,%r12d
jb     1190 <ell_mod+0x80>
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
divsd  %xmm1,%xmm0
mulsd  %xmm0,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @ell_mod(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca i32
store double %0, double* %2
store double 1.000000e+00, double* %4
store double 0.000000e+00, double* %5
store i32 1, i32* %6
%7 = load double, double* @M_PI
%8 = fneg double %7
%9 = load double, double* %2
%10 = fmul double %8, %9
%11 = call i32 @exp(double %10)
%12 = sitofp i32 %11 to double
store double %12, double* %3
br label %13
13: ; preds = %35, %1
%14 = load double, double* @M_PI
%15 = fneg double %14
%16 = load double, double* %2
%17 = fmul double %15, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %6
%20 = mul nsw i32 %18, %19
%21 = load i32, i32* %6
%22 = mul nsw i32 2, %21
%23 = sub nsw i32 %20, %22
%24 = add nsw i32 %23, 1
%25 = sitofp i32 %24 to double
%26 = fmul double %17, %25
%27 = call i32 @exp(double %26)
%28 = sitofp i32 %27 to double
%29 = fcmp ogt double %28, 1.000000e-15
br i1 %29, label %30, label %33
30: ; preds = %13
%31 = load i32, i32* %6
%32 = icmp slt i32 %31, 50
br label %33
33: ; preds = %30, %13
%34 = phi i1 [ false, %13 ], [ %32, %30 ]
br i1 %34, label %35, label %69
35: ; preds = %33
%36 = load double, double* @M_PI
%37 = fneg double %36
%38 = load double, double* %2
%39 = fmul double %37, %38
%40 = load i32, i32* %6
%41 = sitofp i32 %40 to double
%42 = fsub double %41, 5.000000e-01
%43 = fmul double %39, %42
%44 = load i32, i32* %6
%45 = sitofp i32 %44 to double
%46 = fsub double %45, 5.000000e-01
%47 = fmul double %43, %46
%48 = call i32 @exp(double %47)
%49 = mul nsw i32 2, %48
%50 = sitofp i32 %49 to double
%51 = load double, double* %5
%52 = fadd double %51, %50
store double %52, double* %5
%53 = load double, double* @M_PI
%54 = fneg double %53
%55 = load double, double* %2
%56 = fmul double %54, %55
%57 = load i32, i32* %6
%58 = load i32, i32* %6
%59 = mul nsw i32 %57, %58
%60 = sitofp i32 %59 to double
%61 = fmul double %56, %60
%62 = call i32 @exp(double %61)
%63 = mul nsw i32 2, %62
%64 = sitofp i32 %63 to double
%65 = load double, double* %4
%66 = fadd double %65, %64
store double %66, double* %4
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %13
69: ; preds = %33
%70 = load double, double* %5
%71 = load double, double* %4
%72 = fdiv double %70, %71
store double %72, double* %3
%73 = load double, double* %3
%74 = load double, double* %3
%75 = fmul double %73, %74
ret double %75
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @ell_mod(double %0) {
%2 = load double, double* @M_PI
%3 = fneg double %2
%4 = fmul double %3, %0
%5 = tail call i32 @exp(double %4)
%6 = load double, double* @M_PI
%7 = fneg double %6
%8 = fmul double %7, %0
%9 = fmul double %8, 0.000000e+00
%10 = tail call i32 @exp(double %9)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %53
12: ; preds = %1, %12
%13 = phi i32 [ %39, %12 ], [ 1, %1 ]
%14 = phi i32 [ %35, %12 ], [ 1, %1 ]
%15 = phi <2 x double> [ %34, %12 ], [ <double 0.000000e+00, double 1.000000e+00>, %1 ]
%16 = load double, double* @M_PI
%17 = fneg double %16
%18 = fmul double %17, %0
%19 = sitofp i32 %14 to double
%20 = fadd double %19, -5.000000e-01
%21 = fmul double %20, %18
%22 = fmul double %20, %21
%23 = tail call i32 @exp(double %22)
%24 = load double, double* @M_PI
%25 = fneg double %24
%26 = fmul double %25, %0
%27 = sitofp i32 %13 to double
%28 = fmul double %26, %27
%29 = tail call i32 @exp(double %28)
%30 = insertelement <2 x i32> poison, i32 %23, i64 0
%31 = insertelement <2 x i32> %30, i32 %29, i64 1
%32 = shl nsw <2 x i32> %31, <i32 1, i32 1>
%33 = sitofp <2 x i32> %32 to <2 x double>
%34 = fadd <2 x double> %15, %33
%35 = add nuw nsw i32 %14, 1
%36 = load double, double* @M_PI
%37 = fneg double %36
%38 = fmul double %37, %0
%39 = mul nuw nsw i32 %35, %35
%40 = mul nsw i32 %35, -2
%41 = add nuw nsw i32 %39, 1
%42 = add nsw i32 %41, %40
%43 = sitofp i32 %42 to double
%44 = fmul double %38, %43
%45 = tail call i32 @exp(double %44)
%46 = icmp sgt i32 %45, 0
%47 = icmp ult i32 %14, 49
%48 = select i1 %46, i1 %47, i1 false
br i1 %48, label %12, label %49
49: ; preds = %12
%50 = extractelement <2 x double> %34, i64 0
%51 = extractelement <2 x double> %34, i64 1
%52 = fdiv double %50, %51
br label %53
53: ; preds = %49, %1
%54 = phi double [ %52, %49 ], [ 0.000000e+00, %1 ]
%55 = fmul double %54, %54
ret double %55
}