#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);
scalar_t__ signbit(double);
double fmin(double x, double y) {
  if (isnan(x))
    return y;
  if (isnan(y))
    return x;
  if (signbit(x) != signbit(y))
    return signbit(x) ? x : y;
  return x < y ? x : y;
}


x86 assembly (clang, -O0):
<fmin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1155 <fmin+0x35>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1213 <fmin+0xf3>
movsd  -0x18(%rbp),%xmm0
call   1030 <isnan@plt>
cmp    $0x0,%rax
je     1178 <fmin+0x58>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1213 <fmin+0xf3>
movsd  -0x10(%rbp),%xmm0
call   1040 <signbit@plt>
mov    %rax,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <signbit@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     11dc <fmin+0xbc>
movsd  -0x10(%rbp),%xmm0
call   1040 <signbit@plt>
cmp    $0x0,%rax
je     11c3 <fmin+0xa3>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11cd <fmin+0xad>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1213 <fmin+0xf3>
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ff <fmin+0xdf>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1209 <fmin+0xe9>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmin>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
call   1030 <isnan@plt>
test   %rax,%rax
je     1142 <fmin+0x22>
movsd  0x8(%rsp),%xmm0
jmp    1157 <fmin+0x37>
movsd  0x8(%rsp),%xmm0
call   1030 <isnan@plt>
test   %rax,%rax
je     115d <fmin+0x3d>
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret
movsd  (%rsp),%xmm0
call   1040 <signbit@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
call   1040 <signbit@plt>
cmp    %rax,%rbx
jne    1187 <fmin+0x67>
movsd  (%rsp),%xmm0
minsd  0x8(%rsp),%xmm0
jmp    1157 <fmin+0x37>
movsd  (%rsp),%xmm0
call   1040 <signbit@plt>
test   %rax,%rax
movsd  0x8(%rsp),%xmm0
je     1157 <fmin+0x37>
jmp    1152 <fmin+0x32>

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 %43
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 %43
17: ; preds = %11
%18 = load double, double* %4
%19 = call i64 @signbit(double %18)
%20 = load double, double* %5
%21 = call i64 @signbit(double %20)
%22 = icmp ne i64 %19, %21
br i1 %22, label %23, label %33
23: ; preds = %17
%24 = load double, double* %4
%25 = call i64 @signbit(double %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %23
%28 = load double, double* %4
br label %31
29: ; preds = %23
%30 = load double, double* %5
br label %31
31: ; preds = %29, %27
%32 = phi double [ %28, %27 ], [ %30, %29 ]
store double %32, double* %3
br label %43
33: ; preds = %17
%34 = load double, double* %4
%35 = load double, double* %5
%36 = fcmp olt double %34, %35
br i1 %36, label %37, label %39
37: ; preds = %33
%38 = load double, double* %4
br label %41
39: ; preds = %33
%40 = load double, double* %5
br label %41
41: ; preds = %39, %37
%42 = phi double [ %38, %37 ], [ %40, %39 ]
store double %42, double* %3
br label %43
43: ; preds = %41, %31, %15, %9
%44 = load double, double* %3
ret double %44
}

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 %19
5: ; preds = %2
%6 = tail call i64 @isnan(double %1)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %19
8: ; preds = %5
%9 = tail call i64 @signbit(double %0)
%10 = tail call i64 @signbit(double %1)
%11 = icmp eq i64 %9, %10
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = tail call i64 @signbit(double %0)
%14 = icmp eq i64 %13, 0
%15 = select i1 %14, double %1, double %0
br label %19
16: ; preds = %8
%17 = fcmp olt double %0, %1
%18 = select i1 %17, double %0, double %1
br label %19
19: ; preds = %5, %2, %16, %12
%20 = phi double [ %15, %12 ], [ %18, %16 ], [ %1, %2 ], [ %0, %5 ]
ret double %20
}