#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_float(const float *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_float>:
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_float+0x44>
cmpq   $0x0,-0x10(%rbp)
je     1154 <find_bounds_float+0x44>
cmpq   $0x0,-0x18(%rbp)
je     1154 <find_bounds_float+0x44>
cmpq   $0x0,-0x20(%rbp)
jne    115b <find_bounds_float+0x4b>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rax
movss  (%rax),%xmm0
cvtss2sd %xmm0,%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    1221 <find_bounds_float+0x111>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm1
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ce <find_bounds_float+0xbe>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    120b <find_bounds_float+0xfb>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x20(%rbp),%rax
ucomisd (%rax),%xmm0
jbe    1206 <find_bounds_float+0xf6>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
cvtss2sd %xmm0,%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    120b <find_bounds_float+0xfb>
jmp    1210 <find_bounds_float+0x100>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    117f <find_bounds_float+0x6f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<find_bounds_float>:
push   %rax
test   %rdi,%rdi
je     1182 <find_bounds_float+0x72>
test   %rsi,%rsi
je     1182 <find_bounds_float+0x72>
test   %rdx,%rdx
je     1182 <find_bounds_float+0x72>
test   %rcx,%rcx
je     1182 <find_bounds_float+0x72>
movss  (%rdi),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,(%rcx)
movsd  %xmm0,(%rdx)
cmp    $0x2,%rsi
jb     1180 <find_bounds_float+0x70>
add    $0xfffffffffffffffe,%rsi
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movss  0x4(%rdi,%rax,4),%xmm1
cvtss2sd %xmm1,%xmm1
ucomisd %xmm1,%xmm0
mov    %rdx,%r8
ja     116c <find_bounds_float+0x5c>
ucomisd (%rcx),%xmm1
mov    %rcx,%r8
jbe    1171 <find_bounds_float+0x61>
movsd  %xmm1,(%r8)
cmp    %rax,%rsi
je     1180 <find_bounds_float+0x70>
movsd  (%rdx),%xmm0
add    $0x1,%rax
jmp    1150 <find_bounds_float+0x40>
pop    %rax
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define void @find_bounds_float(float* %0, i64 %1, double* %2, double* %3) {
%5 = alloca float*
%6 = alloca i64
%7 = alloca double*
%8 = alloca double*
%9 = alloca i64
store float* %0, float** %5
store i64 %1, i64* %6
store double* %2, double** %7
store double* %3, double** %8
%10 = load float*, float** %5
%11 = icmp eq float* %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 float*, float** %5
%25 = getelementptr inbounds float, float* %24, i64 0
%26 = load float, float* %25
%27 = fpext float %26 to double
%28 = load double*, double** %8
store double %27, double* %28
%29 = load double*, double** %7
store double %27, double* %29
store i64 1, i64* %9
br label %30
30: ; preds = %68, %23
%31 = load i64, i64* %9
%32 = load i64, i64* %6
%33 = icmp ult i64 %31, %32
br i1 %33, label %34, label %71
34: ; preds = %30
%35 = load float*, float** %5
%36 = load i64, i64* %9
%37 = getelementptr inbounds float, float* %35, i64 %36
%38 = load float, float* %37
%39 = fpext float %38 to double
%40 = load double*, double** %7
%41 = load double, double* %40
%42 = fcmp olt double %39, %41
br i1 %42, label %43, label %50
43: ; preds = %34
%44 = load float*, float** %5
%45 = load i64, i64* %9
%46 = getelementptr inbounds float, float* %44, i64 %45
%47 = load float, float* %46
%48 = fpext float %47 to double
%49 = load double*, double** %7
store double %48, double* %49
br label %67
50: ; preds = %34
%51 = load float*, float** %5
%52 = load i64, i64* %9
%53 = getelementptr inbounds float, float* %51, i64 %52
%54 = load float, float* %53
%55 = fpext float %54 to double
%56 = load double*, double** %8
%57 = load double, double* %56
%58 = fcmp ogt double %55, %57
br i1 %58, label %59, label %66
59: ; preds = %50
%60 = load float*, float** %5
%61 = load i64, i64* %9
%62 = getelementptr inbounds float, float* %60, i64 %61
%63 = load float, float* %62
%64 = fpext float %63 to double
%65 = load double*, double** %8
store double %64, double* %65
br label %66
66: ; preds = %59, %50
br label %67
67: ; preds = %66, %43
br label %68
68: ; preds = %67
%69 = load i64, i64* %9
%70 = add i64 %69, 1
store i64 %70, i64* %9
br label %30
71: ; preds = %30
ret void
}

LLVM IR (-O2):
define void @find_bounds_float(float* %0, i64 %1, double* %2, double* %3) {
%5 = icmp eq float* %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 float, float* %0
%16 = fpext float %15 to double
store double %16, double* %3
store double %16, double* %2
%17 = icmp ugt i64 %1, 1
br i1 %17, label %18, label %35
18: ; preds = %14, %33
%19 = phi double [ %34, %33 ], [ %16, %14 ]
%20 = phi i64 [ %31, %33 ], [ 1, %14 ]
%21 = getelementptr inbounds float, float* %0, i64 %20
%22 = load float, float* %21
%23 = fpext float %22 to double
%24 = fcmp ogt double %19, %23
br i1 %24, label %28, label %25
25: ; preds = %18
%26 = load double, double* %3
%27 = fcmp olt double %26, %23
br i1 %27, label %28, label %30
28: ; preds = %25, %18
%29 = phi double* [ %2, %18 ], [ %3, %25 ]
store double %23, double* %29
br label %30
30: ; preds = %28, %25
%31 = add nuw i64 %20, 1
%32 = icmp eq i64 %31, %1
br i1 %32, label %35, label %33
33: ; preds = %30
%34 = load double, double* %2
br label %18
35: ; preds = %30, %14
ret void
}