#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__ fabs(double);
scalar_t__ sign(double);
double fabs_min(double a, double b) {
  if (sign(a) != sign(b))
    return 0.;
  if (fabs(a) < fabs(b))
    return a;
  else
    return b;
}


x86 assembly (clang, -O0):
<fabs_min>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <sign@plt>
mov    %rax,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <sign@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
je     1167 <fabs_min+0x47>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a8 <fabs_min+0x88>
movsd  -0x10(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jge    119e <fabs_min+0x7e>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a8 <fabs_min+0x88>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fabs_min>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,(%rsp)
call   1040 <sign@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
call   1040 <sign@plt>
xorps  %xmm0,%xmm0
cmp    %rax,%rbx
jne    1178 <fabs_min+0x58>
movsd  (%rsp),%xmm0
call   1030 <fabs@plt>
mov    %rax,%rbx
movsd  0x8(%rsp),%xmm0
call   1030 <fabs@plt>
cmp    %rax,%rbx
jl     1173 <fabs_min+0x53>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  (%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @fabs_min(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 @sign(double %6)
%8 = load double, double* %5
%9 = call i64 @sign(double %8)
%10 = icmp ne i64 %7, %9
br i1 %10, label %11, label %12
11: ; preds = %2
store double 0.000000e+00, double* %3
br label %22
12: ; preds = %2
%13 = load double, double* %4
%14 = call i64 @fabs(double %13)
%15 = load double, double* %5
%16 = call i64 @fabs(double %15)
%17 = icmp slt i64 %14, %16
br i1 %17, label %18, label %20
18: ; preds = %12
%19 = load double, double* %4
store double %19, double* %3
br label %22
20: ; preds = %12
%21 = load double, double* %5
store double %21, double* %3
br label %22
22: ; preds = %20, %18, %11
%23 = load double, double* %3
ret double %23
}

LLVM IR (-O2):
define double @fabs_min(double %0, double %1) {
%3 = tail call i64 @sign(double %0)
%4 = tail call i64 @sign(double %1)
%5 = icmp eq i64 %3, %4
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = tail call i64 @fabs(double %0)
%8 = tail call i64 @fabs(double %1)
%9 = icmp slt i64 %7, %8
%10 = select i1 %9, double %0, double %1
br label %11
11: ; preds = %6, %2
%12 = phi double [ 0.000000e+00, %2 ], [ %10, %6 ]
ret double %12
}