#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__ isnan(double);
double fmin(double x, double y) {
  if (isnan(x))
    return y;
  if (isnan(y))
    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 <isnan@plt>
cmp    $0x0,%rax
je     1145 <fmin+0x35>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    119f <fmin+0x8f>
movsd  -0x18(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1168 <fmin+0x58>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    119f <fmin+0x8f>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    118b <fmin+0x7b>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1195 <fmin+0x85>
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>:
sub    $0x18,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
call   1030 <isnan@plt>
test   %rax,%rax
je     1135 <fmin+0x25>
movsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  0x8(%rsp),%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
je     1150 <fmin+0x40>
movsd  0x10(%rsp),%xmm0
add    $0x18,%rsp
ret
movsd  0x10(%rsp),%xmm0
minsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
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 @isnan(double %6)
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = load double, double* %5
store double %10, double* %3
br label %27
11: ; preds = %2
%12 = load double, double* %5
%13 = call i64 @isnan(double %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = load double, double* %4
store double %16, double* %3
br label %27
17: ; preds = %11
%18 = load double, double* %4
%19 = load double, double* %5
%20 = fcmp olt double %18, %19
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = load double, double* %4
br label %25
23: ; preds = %17
%24 = load double, double* %5
br label %25
25: ; preds = %23, %21
%26 = phi double [ %22, %21 ], [ %24, %23 ]
store double %26, double* %3
br label %27
27: ; preds = %25, %15, %9
%28 = load double, double* %3
ret double %28
}

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