#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 _ada_use_c2phc(int, int *, int *, double *);
int numbtrop_quaddobl_retrieve(int nbt, int dim, int *wnd, double *dir,
                               double *err) {
  int fail, k;
  int nd[2];
  double cff[4 * nbt * (dim + 1)];
  nd[0] = nbt;
  nd[1] = dim;
  fail = _ada_use_c2phc(719, nd, wnd, cff);
  for (k = 0; k < 4 * nbt * dim; k++)
    dir[k] = cff[k];
  for (k = 0; k < 4 * nbt; k++)
    err[k] = cff[4 * nbt * dim + k];
  return fail;
}


x86 assembly (clang, -O0):
<numbtrop_quaddobl_retrieve>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
imul   %ecx,%eax
shl    $0x2,%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rax,%rdx
shl    $0x3,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    -0x30(%rbp),%rsi
mov    -0x10(%rbp),%rdx
mov    $0x2cf,%edi
call   1030 <_ada_use_c2phc@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x2,%ecx
imul   -0x8(%rbp),%ecx
cmp    %ecx,%eax
jge    11bd <numbtrop_quaddobl_retrieve+0xad>
mov    -0x48(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1180 <numbtrop_quaddobl_retrieve+0x70>
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x4(%rbp),%ecx
shl    $0x2,%ecx
cmp    %ecx,%eax
jge    1209 <numbtrop_quaddobl_retrieve+0xf9>
mov    -0x48(%rbp),%rax
mov    -0x4(%rbp),%ecx
shl    $0x2,%ecx
imul   -0x8(%rbp),%ecx
add    -0x28(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11c4 <numbtrop_quaddobl_retrieve+0xb4>
mov    -0x24(%rbp),%eax
mov    -0x38(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<numbtrop_quaddobl_retrieve>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,-0x40(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %esi,%ebx
mov    %edi,%r15d
mov    %rsp,-0x48(%rbp)
lea    0x0(,%r15,4),%r12d
lea    0x1(%rbx),%eax
imul   %r12d,%eax
shl    $0x3,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    %edi,-0x30(%rbp)
mov    %esi,-0x2c(%rbp)
lea    -0x30(%rbp),%rsi
mov    $0x2cf,%edi
mov    %r14,%rcx
call   1040 <_ada_use_c2phc@plt>
mov    %eax,%r13d
imul   %r12d,%ebx
test   %ebx,%ebx
jle    1192 <numbtrop_quaddobl_retrieve+0x72>
mov    %ebx,%edx
shl    $0x3,%rdx
mov    -0x38(%rbp),%rdi
mov    %r14,%rsi
call   1030 <memcpy@plt>
test   %r15d,%r15d
jle    11b8 <numbtrop_quaddobl_retrieve+0x98>
movslq %ebx,%rax
lea    (%r14,%rax,8),%rsi
cmp    $0x2,%r12d
mov    $0x1,%edx
cmovge %r12d,%edx
shl    $0x3,%rdx
mov    -0x40(%rbp),%rdi
call   1030 <memcpy@plt>
mov    -0x48(%rbp),%rsp
mov    %r13d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @numbtrop_quaddobl_retrieve(i32 %0, i32 %1, i32* %2, double* %3, double* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca double*
%10 = alloca double*
%11 = alloca i32
%12 = alloca i32
%13 = alloca [2 x i32]
%14 = alloca i8*
%15 = alloca i64
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32* %2, i32** %8
store double* %3, double** %9
store double* %4, double** %10
%16 = load i32, i32* %6
%17 = mul nsw i32 4, %16
%18 = load i32, i32* %7
%19 = add nsw i32 %18, 1
%20 = mul nsw i32 %17, %19
%21 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
store i8* %22, i8** %14
%23 = alloca double, i64 %21
store i64 %21, i64* %15
%24 = load i32, i32* %6
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
store i32 %24, i32* %25
%26 = load i32, i32* %7
%27 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 1
store i32 %26, i32* %27
%28 = getelementptr inbounds [2 x i32], [2 x i32]* %13, i64 0, i64 0
%29 = load i32*, i32** %8
%30 = call i32 @_ada_use_c2phc(i32 719, i32* %28, i32* %29, double* %23)
store i32 %30, i32* %11
store i32 0, i32* %12
br label %31
31: ; preds = %47, %5
%32 = load i32, i32* %12
%33 = load i32, i32* %6
%34 = mul nsw i32 4, %33
%35 = load i32, i32* %7
%36 = mul nsw i32 %34, %35
%37 = icmp slt i32 %32, %36
br i1 %37, label %38, label %50
38: ; preds = %31
%39 = load i32, i32* %12
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %23, i64 %40
%42 = load double, double* %41
%43 = load double*, double** %9
%44 = load i32, i32* %12
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds double, double* %43, i64 %45
store double %42, double* %46
br label %47
47: ; preds = %38
%48 = load i32, i32* %12
%49 = add nsw i32 %48, 1
store i32 %49, i32* %12
br label %31
50: ; preds = %31
store i32 0, i32* %12
br label %51
51: ; preds = %70, %50
%52 = load i32, i32* %12
%53 = load i32, i32* %6
%54 = mul nsw i32 4, %53
%55 = icmp slt i32 %52, %54
br i1 %55, label %56, label %73
56: ; preds = %51
%57 = load i32, i32* %6
%58 = mul nsw i32 4, %57
%59 = load i32, i32* %7
%60 = mul nsw i32 %58, %59
%61 = load i32, i32* %12
%62 = add nsw i32 %60, %61
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds double, double* %23, i64 %63
%65 = load double, double* %64
%66 = load double*, double** %10
%67 = load i32, i32* %12
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds double, double* %66, i64 %68
store double %65, double* %69
br label %70
70: ; preds = %56
%71 = load i32, i32* %12
%72 = add nsw i32 %71, 1
store i32 %72, i32* %12
br label %51
73: ; preds = %51
%74 = load i32, i32* %11
%75 = load i8*, i8** %14
ret i32 %74
}

LLVM IR (-O2):
define i32 @numbtrop_quaddobl_retrieve(i32 %0, i32 %1, i32* %2, double* nocapture writeonly %3, double* nocapture writeonly %4) {
%6 = bitcast double* %4 to i8*
%7 = alloca [2 x i32]
%8 = bitcast [2 x i32]* %7 to i8*
%9 = shl i32 %0, 2
%10 = add nsw i32 %1, 1
%11 = mul nsw i32 %10, %9
%12 = zext i32 %11 to i64
%13 = tail call i8* @llvm.stacksave()
%14 = alloca double, i64 %12
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 0
store i32 %0, i32* %15
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %7, i64 0, i64 1
store i32 %1, i32* %16
%17 = call i32 @_ada_use_c2phc(i32 719, i32* %15, i32* %2, double* %14)
%18 = mul i32 %9, %1
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %25
20: ; preds = %5
%21 = bitcast double* %14 to i8*
%22 = bitcast double* %3 to i8*
%23 = zext i32 %18 to i64
%24 = shl nuw nsw i64 %23, 3
br label %25
25: ; preds = %20, %5
%26 = icmp sgt i32 %0, 0
br i1 %26, label %27, label %34
27: ; preds = %25
%28 = sext i32 %18 to i64
%29 = getelementptr double, double* %14, i64 %28
%30 = bitcast double* %29 to i8*
%31 = call i32 @llvm.smax.i32(i32 %9, i32 1)
%32 = zext i32 %31 to i64
%33 = shl nuw nsw i64 %32, 3
br label %34
34: ; preds = %27, %25
ret i32 %17
}