#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 const);
scalar_t__ stdlib_base_is_nan(double);
double stdlib_strided_dminabs(const int64_t N, const double *X,
                              const int64_t stride) {
  double min;
  int64_t ix;
  int64_t i;
  double v;
  if (N <= 0) {
    return 0.0 / 0.0;
  }
  if (N == 1 || stride == 0) {
    return fabs(X[0]);
  }
  if (stride < 0) {
    ix = (1 - N) * stride;
  } else {
    ix = 0;
  }
  min = fabs(X[ix]);
  for (i = 1; i < N; i++) {
    ix += stride;
    v = fabs(X[ix]);
    if (stdlib_base_is_nan(v)) {
      return v;
    }
    if (v < min) {
      min = v;
    }
  }
  return min;
}


x86 assembly (clang, -O0):
<stdlib_strided_dminabs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     113e <stdlib_strided_dminabs+0x2e>
movsd  0xedc(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1248 <stdlib_strided_dminabs+0x138>
cmpl   $0x1,-0xc(%rbp)
je     1152 <stdlib_strided_dminabs+0x42>
cmpl   $0x0,-0x1c(%rbp)
jne    116f <stdlib_strided_dminabs+0x5f>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
movaps 0xe9f(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1248 <stdlib_strided_dminabs+0x138>
cmpl   $0x0,-0x1c(%rbp)
jge    118d <stdlib_strided_dminabs+0x7d>
mov    $0x1,%eax
sub    -0xc(%rbp),%eax
imul   -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1194 <stdlib_strided_dminabs+0x84>
movl   $0x0,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe58(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    123e <stdlib_strided_dminabs+0x12e>
mov    -0x1c(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movaps 0xe1f(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
call   1030 <stdlib_base_is_nan@plt>
cmp    $0x0,%rax
je     120d <stdlib_strided_dminabs+0xfd>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1248 <stdlib_strided_dminabs+0x138>
movsd  -0x38(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    122b <stdlib_strided_dminabs+0x11b>
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    1230 <stdlib_strided_dminabs+0x120>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11b8 <stdlib_strided_dminabs+0xa8>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stdlib_strided_dminabs>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
test   %edi,%edi
jle    1198 <stdlib_strided_dminabs+0x88>
mov    %edi,%ebp
cmp    $0x1,%edi
je     11a2 <stdlib_strided_dminabs+0x92>
test   %edx,%edx
je     11a2 <stdlib_strided_dminabs+0x92>
mov    $0x1,%eax
sub    %ebp,%eax
imul   %edx,%eax
movslq %edx,%r14
sar    $0x1f,%edx
and    %eax,%edx
movslq %edx,%rax
movsd  (%rsi,%rax,8),%xmm1
andpd  0xec7(%rip),%xmm1
add    %r14,%rax
lea    (%rsi,%rax,8),%rbx
shl    $0x3,%r14
add    $0xffffffff,%ebp
nopw   0x0(%rax,%rax,1)
movapd %xmm1,0x10(%rsp)
movsd  (%rbx),%xmm0
andps  0xe9f(%rip),%xmm0
movaps %xmm0,(%rsp)
call   1030 <stdlib_base_is_nan@plt>
test   %rax,%rax
jne    11b0 <stdlib_strided_dminabs+0xa0>
movapd (%rsp),%xmm0
minsd  0x10(%rsp),%xmm0
add    %r14,%rbx
movapd %xmm0,%xmm1
add    $0xffffffff,%ebp
jne    1160 <stdlib_strided_dminabs+0x50>
jmp    11b4 <stdlib_strided_dminabs+0xa4>
movsd  0xe60(%rip),%xmm0
jmp    11b4 <stdlib_strided_dminabs+0xa4>
movsd  (%rsi),%xmm0
andpd  0xe62(%rip),%xmm0
jmp    11b4 <stdlib_strided_dminabs+0xa4>
movaps (%rsp),%xmm0
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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