#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 /*<<< orphan*/ abort();
void find_bounds_double(const double *values, size_t num, double *min,
                        double *max) {
  size_t idx;
  if (values == NULL || num == 0 || min == NULL || max == NULL)
    abort();
  *min = *max = values[0];
  for (idx = 1; idx < num; ++idx) {
    if (values[idx] < *min)
      *min = values[idx];
    else if (values[idx] > *max)
      *max = values[idx];
  }
}


x86 assembly (clang, -O0):
<find_bounds_double>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1154 <find_bounds_double+0x44>
cmpq   $0x0,-0x10(%rbp)
je     1154 <find_bounds_double+0x44>
cmpq   $0x0,-0x18(%rbp)
je     1154 <find_bounds_double+0x44>
cmpq   $0x0,-0x20(%rbp)
jne    115b <find_bounds_double+0x4b>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    120d <find_bounds_double+0xfd>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c2 <find_bounds_double+0xb2>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11f7 <find_bounds_double+0xe7>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    11f2 <find_bounds_double+0xe2>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    11f7 <find_bounds_double+0xe7>
jmp    11fc <find_bounds_double+0xec>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    117b <find_bounds_double+0x6b>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_bounds_double>:
push   %rax
test   %rdi,%rdi
je     116e <find_bounds_double+0x5e>
test   %rsi,%rsi
je     116e <find_bounds_double+0x5e>
test   %rdx,%rdx
je     116e <find_bounds_double+0x5e>
test   %rcx,%rcx
je     116e <find_bounds_double+0x5e>
movsd  (%rdi),%xmm0
movsd  %xmm0,(%rcx)
movsd  %xmm0,(%rdx)
cmp    $0x2,%rsi
jb     116c <find_bounds_double+0x5c>
add    $0xfffffffffffffffe,%rsi
xor    %eax,%eax
nopl   (%rax)
movsd  0x8(%rdi,%rax,8),%xmm1
ucomisd %xmm1,%xmm0
mov    %rdx,%r8
ja     1158 <find_bounds_double+0x48>
ucomisd (%rcx),%xmm1
mov    %rcx,%r8
jbe    115d <find_bounds_double+0x4d>
movsd  %xmm1,(%r8)
cmp    %rax,%rsi
je     116c <find_bounds_double+0x5c>
movsd  (%rdx),%xmm0
add    $0x1,%rax
jmp    1140 <find_bounds_double+0x30>
pop    %rax
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define void @find_bounds_double(double* %0, i64 %1, double* %2, double* %3) {
%5 = alloca double*
%6 = alloca i64
%7 = alloca double*
%8 = alloca double*
%9 = alloca i64
store double* %0, double** %5
store i64 %1, i64* %6
store double* %2, double** %7
store double* %3, double** %8
%10 = load double*, double** %5
%11 = icmp eq double* %10, null
br i1 %11, label %21, label %12
12: ; preds = %4
%13 = load i64, i64* %6
%14 = icmp eq i64 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = load double*, double** %7
%17 = icmp eq double* %16, null
br i1 %17, label %21, label %18
18: ; preds = %15
%19 = load double*, double** %8
%20 = icmp eq double* %19, null
br i1 %20, label %21, label %23
21: ; preds = %18, %15, %12, %4
%22 = call i32 (...) @abort()
unreachable
23: ; preds = %18
%24 = load double*, double** %5
%25 = getelementptr inbounds double, double* %24, i64 0
%26 = load double, double* %25
%27 = load double*, double** %8
store double %26, double* %27
%28 = load double*, double** %7
store double %26, double* %28
store i64 1, i64* %9
br label %29
29: ; preds = %63, %23
%30 = load i64, i64* %9
%31 = load i64, i64* %6
%32 = icmp ult i64 %30, %31
br i1 %32, label %33, label %66
33: ; preds = %29
%34 = load double*, double** %5
%35 = load i64, i64* %9
%36 = getelementptr inbounds double, double* %34, i64 %35
%37 = load double, double* %36
%38 = load double*, double** %7
%39 = load double, double* %38
%40 = fcmp olt double %37, %39
br i1 %40, label %41, label %47
41: ; preds = %33
%42 = load double*, double** %5
%43 = load i64, i64* %9
%44 = getelementptr inbounds double, double* %42, i64 %43
%45 = load double, double* %44
%46 = load double*, double** %7
store double %45, double* %46
br label %62
47: ; preds = %33
%48 = load double*, double** %5
%49 = load i64, i64* %9
%50 = getelementptr inbounds double, double* %48, i64 %49
%51 = load double, double* %50
%52 = load double*, double** %8
%53 = load double, double* %52
%54 = fcmp ogt double %51, %53
br i1 %54, label %55, label %61
55: ; preds = %47
%56 = load double*, double** %5
%57 = load i64, i64* %9
%58 = getelementptr inbounds double, double* %56, i64 %57
%59 = load double, double* %58
%60 = load double*, double** %8
store double %59, double* %60
br label %61
61: ; preds = %55, %47
br label %62
62: ; preds = %61, %41
br label %63
63: ; preds = %62
%64 = load i64, i64* %9
%65 = add i64 %64, 1
store i64 %65, i64* %9
br label %29
66: ; preds = %29
ret void
}

LLVM IR (-O2):
define void @find_bounds_double(double* %0, i64 %1, double* %2, double* %3) {
%5 = icmp eq double* %0, null
%6 = icmp eq i64 %1, 0
%7 = or i1 %5, %6
%8 = icmp eq double* %2, null
%9 = or i1 %7, %8
%10 = icmp eq double* %3, null
%11 = or i1 %9, %10
br i1 %11, label %12, label %14
12: ; preds = %4
%13 = tail call i32 (...) @abort()
unreachable
14: ; preds = %4
%15 = load double, double* %0
store double %15, double* %3
store double %15, double* %2
%16 = icmp ugt i64 %1, 1
br i1 %16, label %17, label %33
17: ; preds = %14, %31
%18 = phi double [ %32, %31 ], [ %15, %14 ]
%19 = phi i64 [ %29, %31 ], [ 1, %14 ]
%20 = getelementptr inbounds double, double* %0, i64 %19
%21 = load double, double* %20
%22 = fcmp olt double %21, %18
br i1 %22, label %26, label %23
23: ; preds = %17
%24 = load double, double* %3
%25 = fcmp ogt double %21, %24
br i1 %25, label %26, label %28
26: ; preds = %23, %17
%27 = phi double* [ %2, %17 ], [ %3, %23 ]
store double %21, double* %27
br label %28
28: ; preds = %26, %23
%29 = add nuw i64 %19, 1
%30 = icmp eq i64 %29, %1
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = load double, double* %2
br label %17
33: ; preds = %28, %14
ret void
}