#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 */
typedef int int64_t;

/* Variables and functions */
double fabs(double);
scalar_t__ stdlib_base_is_nan(double);
double stdlib_strided_dmaxabssorted(const int64_t N, const double *X,
                                    const int64_t stride) {
  double v1;
  double v2;
  if (N <= 0) {
    return 0.0 / 0.0;
  }
  if (N == 1 || stride == 0) {
    return X[0];
  }
  if (stride < 0) {
    v1 = X[(1 - N) * stride];
    v2 = X[0];
  } else {
    v1 = X[0];
    v2 = X[(N - 1) * stride];
  }
  if (stdlib_base_is_nan(v1) || stdlib_base_is_nan(v2)) {
    return 0.0 / 0.0;
  }
  v1 = fabs(v1);
  v2 = fabs(v2);
  if (v1 > v2) {
    return v1;
  }
  return v2;
}


x86 assembly (clang, -O0):
<stdlib_strided_dmaxabssorted>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     113e <stdlib_strided_dmaxabssorted+0x2e>
movsd  0xedc(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1252 <stdlib_strided_dmaxabssorted+0x142>
cmpl   $0x1,-0xc(%rbp)
je     1152 <stdlib_strided_dmaxabssorted+0x42>
cmpl   $0x0,-0x1c(%rbp)
jne    1164 <stdlib_strided_dmaxabssorted+0x54>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1252 <stdlib_strided_dmaxabssorted+0x142>
cmpl   $0x0,-0x1c(%rbp)
jge    119d <stdlib_strided_dmaxabssorted+0x8d>
mov    -0x18(%rbp),%rax
mov    $0x1,%ecx
sub    -0xc(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11c5 <stdlib_strided_dmaxabssorted+0xb5>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x18(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
imul   -0x1c(%rbp),%ecx
movslq %ecx,%rcx
movsd  (%rax,%rcx,8),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
call   1030 <stdlib_base_is_nan@plt>
cmp    $0x0,%rax
jne    11ed <stdlib_strided_dmaxabssorted+0xdd>
movsd  -0x30(%rbp),%xmm0
call   1030 <stdlib_base_is_nan@plt>
cmp    $0x0,%rax
je     11ff <stdlib_strided_dmaxabssorted+0xef>
movsd  0xe1b(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1252 <stdlib_strided_dmaxabssorted+0x142>
movsd  -0x28(%rbp),%xmm0
movaps 0xdf5(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movaps 0xde0(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    1248 <stdlib_strided_dmaxabssorted+0x138>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1252 <stdlib_strided_dmaxabssorted+0x142>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdlib_strided_dmaxabssorted>:
sub    $0x28,%rsp
movsd  0xee4(%rip),%xmm0
test   %edi,%edi
jle    1194 <stdlib_strided_dmaxabssorted+0x84>
cmp    $0x1,%edi
je     113d <stdlib_strided_dmaxabssorted+0x2d>
test   %edx,%edx
je     113d <stdlib_strided_dmaxabssorted+0x2d>
js     1146 <stdlib_strided_dmaxabssorted+0x36>
add    $0xffffffff,%edi
imul   %edx,%edi
movslq %edi,%rcx
mov    %rsi,%rax
lea    (%rsi,%rcx,8),%rsi
jmp    1156 <stdlib_strided_dmaxabssorted+0x46>
movsd  (%rsi),%xmm0
add    $0x28,%rsp
ret
mov    $0x1,%eax
sub    %edi,%eax
imul   %edx,%eax
cltq
lea    (%rsi,%rax,8),%rax
movsd  (%rsi),%xmm0
movaps %xmm0,(%rsp)
movsd  (%rax),%xmm0
movaps %xmm0,0x10(%rsp)
call   1030 <stdlib_base_is_nan@plt>
test   %rax,%rax
je     117e <stdlib_strided_dmaxabssorted+0x6e>
movsd  0xe87(%rip),%xmm0
add    $0x28,%rsp
ret
movaps (%rsp),%xmm0
call   1030 <stdlib_base_is_nan@plt>
test   %rax,%rax
movsd  0xe6e(%rip),%xmm0
je     1199 <stdlib_strided_dmaxabssorted+0x89>
add    $0x28,%rsp
ret
movapd 0xe6f(%rip),%xmm0
movapd 0x10(%rsp),%xmm1
andpd  %xmm0,%xmm1
movapd (%rsp),%xmm2
andpd  %xmm0,%xmm2
maxsd  %xmm2,%xmm1
movapd %xmm1,%xmm0
add    $0x28,%rsp
ret

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

LLVM IR (-O2):
define double @stdlib_strided_dmaxabssorted(i32 %0, double* nocapture %1, i32 %2) {
%4 = icmp slt i32 %0, 1
br i1 %4, label %38, label %5
5: ; preds = %3
%6 = icmp eq i32 %0, 1
%7 = icmp eq i32 %2, 0
%8 = or i1 %6, %7
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = load double, double* %1
br label %38
11: ; preds = %5
%12 = icmp slt i32 %2, 0
br i1 %12, label %13, label %18
13: ; preds = %11
%14 = sub nsw i32 1, %0
%15 = mul nsw i32 %14, %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds double, double* %1, i64 %16
br label %23
18: ; preds = %11
%19 = add nsw i32 %0, -1
%20 = mul nsw i32 %19, %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %1, i64 %21
br label %23
23: ; preds = %18, %13
%24 = phi double* [ %17, %13 ], [ %1, %18 ]
%25 = phi double* [ %1, %13 ], [ %22, %18 ]
%26 = load double, double* %25
%27 = load double, double* %24
%28 = tail call i64 @stdlib_base_is_nan(double %27)
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %38
30: ; preds = %23
%31 = tail call i64 @stdlib_base_is_nan(double %26)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %30
%34 = tail call double @llvm.fabs.f64(double %27)
%35 = tail call double @llvm.fabs.f64(double %26)
%36 = fcmp ogt double %34, %35
%37 = select i1 %36, double %34, double %35
br label %38
38: ; preds = %33, %23, %30, %3, %9
%39 = phi double [ %10, %9 ], [ 0x7FF8000000000000, %3 ], [ 0x7FF8000000000000, %30 ], [ 0x7FF8000000000000, %23 ], [ %37, %33 ]
ret double %39
}