#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 DBL_EPSILON;
int /*<<< orphan*/ cpledn(size_t, size_t, double *, double, int, double *,
                          double *, double *);
double fabs(double);
void gawl(double *pfn, double *pl, double *pw, size_t kn) {
  double pmod = 0;
  int iflag;
  int itemax;
  double zw = 0;
  double zdlx;
  double zdlxn = 0;
  iflag = 0;
  itemax = 20;
  size_t iodd = (kn % 2);
  zdlx = *pl;
  for (int jter = 1; jter <= itemax + 1; jter++) {
    cpledn(kn, iodd, pfn, zdlx, iflag, &zw, &zdlxn, &pmod);
    zdlx = zdlxn;
    if (iflag == 1)
      break;
    if (fabs(pmod) <= DBL_EPSILON * 1000.0)
      iflag = 1;
  }
  *pl = zdlxn;
  *pw = zw;
  return;
}


x86 assembly (clang, -O0):
<gawl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x14,-0x30(%rbp)
mov    -0x20(%rbp),%rax
and    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jg     1208 <gawl+0xf8>
mov    -0x20(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x8(%rbp),%rdx
movsd  -0x40(%rbp),%xmm0
mov    -0x2c(%rbp),%ecx
lea    -0x38(%rbp),%r8
lea    -0x48(%rbp),%r9
lea    -0x28(%rbp),%rax
mov    %rax,(%rsp)
call   1030 <cpledn@plt>
movsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
cmpl   $0x1,-0x2c(%rbp)
jne    11c1 <gawl+0xb1>
jmp    1208 <gawl+0xf8>
movsd  -0x28(%rbp),%xmm1
movaps 0xe43(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xe27(%rip),%xmm0
mov    0x2e08(%rip),%rax
mulsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     11f5 <gawl+0xe5>
movl   $0x1,-0x2c(%rbp)
jmp    11fa <gawl+0xea>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    116e <gawl+0x5e>
movsd  -0x48(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gawl>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rcx,%r13
mov    %rdx,0x30(%rsp)
mov    %rdi,%r12
movq   $0x0,0x20(%rsp)
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
mov    %r13d,%ebx
and    $0x1,%ebx
xor    %r15d,%r15d
mov    $0x15,%ebp
lea    0x10(%rsp),%r14
mov    %rsi,0x28(%rsp)
mov    %rsi,%rax
nop
movsd  (%rax),%xmm0
lea    0x20(%rsp),%rax
mov    %rax,(%rsp)
mov    %r13,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
mov    %r15d,%ecx
lea    0x18(%rsp),%r8
mov    %r14,%r9
call   1030 <cpledn@plt>
cmp    $0x1,%r15d
je     11c0 <gawl+0xb0>
movsd  0x20(%rsp),%xmm0
andpd  0xe66(%rip),%xmm0
mov    0x2e47(%rip),%rax
movsd  (%rax),%xmm1
mulsd  0xe63(%rip),%xmm1
xor    %r15d,%r15d
ucomisd %xmm0,%xmm1
setae  %r15b
mov    %r14,%rax
add    $0xffffffff,%ebp
jne    1160 <gawl+0x50>
movsd  0x10(%rsp),%xmm0
mov    0x28(%rsp),%rax
movsd  %xmm0,(%rax)
movsd  0x18(%rsp),%xmm0
mov    0x30(%rsp),%rax
movsd  %xmm0,(%rax)
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@DBL_EPSILON = global double 0.000000e+00
define void @gawl(double* %0, double* %1, double* %2, i64 %3) {
%5 = alloca double*
%6 = alloca double*
%7 = alloca double*
%8 = alloca i64
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca i64
%16 = alloca i32
store double* %0, double** %5
store double* %1, double** %6
store double* %2, double** %7
store i64 %3, i64* %8
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %12
store double 0.000000e+00, double* %14
store i32 0, i32* %10
store i32 20, i32* %11
%17 = load i64, i64* %8
%18 = urem i64 %17, 2
store i64 %18, i64* %15
%19 = load double*, double** %6
%20 = load double, double* %19
store double %20, double* %13
store i32 1, i32* %16
br label %21
21: ; preds = %45, %4
%22 = load i32, i32* %16
%23 = load i32, i32* %11
%24 = add nsw i32 %23, 1
%25 = icmp sle i32 %22, %24
br i1 %25, label %26, label %48
26: ; preds = %21
%27 = load i64, i64* %8
%28 = load i64, i64* %15
%29 = load double*, double** %5
%30 = load double, double* %13
%31 = load i32, i32* %10
%32 = call i32 @cpledn(i64 %27, i64 %28, double* %29, double %30, i32 %31, double* %12, double* %14, double* %9)
%33 = load double, double* %14
store double %33, double* %13
%34 = load i32, i32* %10
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %37
36: ; preds = %26
br label %48
37: ; preds = %26
%38 = load double, double* %9
%39 = call double @llvm.fabs.f64(double %38)
%40 = load double, double* @DBL_EPSILON
%41 = fmul double %40, 1.000000e+03
%42 = fcmp ole double %39, %41
br i1 %42, label %43, label %44
43: ; preds = %37
store i32 1, i32* %10
br label %44
44: ; preds = %43, %37
br label %45
45: ; preds = %44
%46 = load i32, i32* %16
%47 = add nsw i32 %46, 1
store i32 %47, i32* %16
br label %21
48: ; preds = %36, %21
%49 = load double, double* %14
%50 = load double*, double** %6
store double %49, double* %50
%51 = load double, double* %12
%52 = load double*, double** %7
store double %51, double* %52
ret void
}

LLVM IR (-O2):
@DBL_EPSILON = global double 0.000000e+00
define void @gawl(double* %0, double* nocapture %1, double* nocapture writeonly %2, i64 %3) {
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%9 = bitcast double* %6 to i8*
store double 0.000000e+00, double* %6
%10 = bitcast double* %7 to i8*
store double 0.000000e+00, double* %7
%11 = and i64 %3, 1
br label %12
12: ; preds = %4, %19
%13 = phi i32 [ 1, %4 ], [ %26, %19 ]
%14 = phi i32 [ 0, %4 ], [ %25, %19 ]
%15 = phi double* [ %1, %4 ], [ %7, %19 ]
%16 = load double, double* %15
%17 = call i32 @cpledn(i64 %3, i64 %11, double* %0, double %16, i32 %14, double* %6, double* %7, double* %5)
%18 = icmp eq i32 %14, 1
br i1 %18, label %28, label %19
19: ; preds = %12
%20 = load double, double* %5
%21 = call double @llvm.fabs.f64(double %20)
%22 = load double, double* @DBL_EPSILON
%23 = fmul double %22, 1.000000e+03
%24 = fcmp ole double %21, %23
%25 = zext i1 %24 to i32
%26 = add nuw nsw i32 %13, 1
%27 = icmp eq i32 %26, 22
br i1 %27, label %28, label %12
28: ; preds = %12, %19
%29 = load double, double* %7
store double %29, double* %1
%30 = load double, double* %6
store double %30, double* %2
ret void
}