#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 */
scalar_t__ FP_NAN;
scalar_t__ fpclassify(double);
double fmin(double x, double y) {
  if (fpclassify(x) == FP_NAN)
    return y;
  if (fpclassify(y) == FP_NAN)
    return x;
  return x < y ? x : y;
}


x86 assembly (clang, -O0):
<fmin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <fpclassify@plt>
mov    0x2eb5(%rip),%rcx
cmp    (%rcx),%rax
jne    114b <fmin+0x3b>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ab <fmin+0x9b>
movsd  -0x18(%rbp),%xmm0
call   1030 <fpclassify@plt>
mov    0x2e8c(%rip),%rcx
cmp    (%rcx),%rax
jne    1174 <fmin+0x64>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11ab <fmin+0x9b>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    1197 <fmin+0x87>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    11a1 <fmin+0x91>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmin>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
call   1030 <fpclassify@plt>
mov    0x2ebc(%rip),%rbx
cmp    (%rbx),%rax
jne    1138 <fmin+0x28>
movsd  (%rsp),%xmm0
jmp    115a <fmin+0x4a>
movsd  (%rsp),%xmm0
call   1030 <fpclassify@plt>
cmp    (%rbx),%rax
jne    114f <fmin+0x3f>
movsd  0x8(%rsp),%xmm0
jmp    115a <fmin+0x4a>
movsd  0x8(%rsp),%xmm0
minsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@FP_NAN = global i64 0
define double @fmin(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = call i64 @fpclassify(double %6)
%8 = load i64, i64* @FP_NAN
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = load double, double* %5
store double %11, double* %3
br label %29
12: ; preds = %2
%13 = load double, double* %5
%14 = call i64 @fpclassify(double %13)
%15 = load i64, i64* @FP_NAN
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = load double, double* %4
store double %18, double* %3
br label %29
19: ; preds = %12
%20 = load double, double* %4
%21 = load double, double* %5
%22 = fcmp olt double %20, %21
br i1 %22, label %23, label %25
23: ; preds = %19
%24 = load double, double* %4
br label %27
25: ; preds = %19
%26 = load double, double* %5
br label %27
27: ; preds = %25, %23
%28 = phi double [ %24, %23 ], [ %26, %25 ]
store double %28, double* %3
br label %29
29: ; preds = %27, %17, %10
%30 = load double, double* %3
ret double %30
}

LLVM IR (-O2):
@FP_NAN = global i64 0
define double @fmin(double %0, double %1) {
%3 = tail call i64 @fpclassify(double %0)
%4 = load i64, i64* @FP_NAN
%5 = icmp eq i64 %3, %4
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = tail call i64 @fpclassify(double %1)
%8 = load i64, i64* @FP_NAN
%9 = icmp eq i64 %7, %8
br i1 %9, label %13, label %10
10: ; preds = %6
%11 = fcmp olt double %0, %1
%12 = select i1 %11, double %0, double %1
br label %13
13: ; preds = %6, %2, %10
%14 = phi double [ %12, %10 ], [ %1, %2 ], [ %0, %6 ]
ret double %14
}